babylon.module.d.ts 5.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835
  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. }
  57164. /**
  57165. * Block used to apply trigonometry operation to floats
  57166. */
  57167. export class TrigonometryBlock extends NodeMaterialBlock {
  57168. /**
  57169. * Gets or sets the operation applied by the block
  57170. */
  57171. operation: TrigonometryBlockOperations;
  57172. /**
  57173. * Creates a new TrigonometryBlock
  57174. * @param name defines the block name
  57175. */
  57176. constructor(name: string);
  57177. /**
  57178. * Gets the current class name
  57179. * @returns the class name
  57180. */
  57181. getClassName(): string;
  57182. /**
  57183. * Gets the input component
  57184. */
  57185. readonly input: NodeMaterialConnectionPoint;
  57186. /**
  57187. * Gets the output component
  57188. */
  57189. readonly output: NodeMaterialConnectionPoint;
  57190. protected _buildBlock(state: NodeMaterialBuildState): this;
  57191. serialize(): any;
  57192. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57193. }
  57194. }
  57195. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57196. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57197. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57198. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57199. /**
  57200. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57201. */
  57202. export class ColorMergerBlock extends NodeMaterialBlock {
  57203. /**
  57204. * Create a new ColorMergerBlock
  57205. * @param name defines the block name
  57206. */
  57207. constructor(name: string);
  57208. /**
  57209. * Gets the current class name
  57210. * @returns the class name
  57211. */
  57212. getClassName(): string;
  57213. /**
  57214. * Gets the r component (input)
  57215. */
  57216. readonly r: NodeMaterialConnectionPoint;
  57217. /**
  57218. * Gets the g component (input)
  57219. */
  57220. readonly g: NodeMaterialConnectionPoint;
  57221. /**
  57222. * Gets the b component (input)
  57223. */
  57224. readonly b: NodeMaterialConnectionPoint;
  57225. /**
  57226. * Gets the a component (input)
  57227. */
  57228. readonly a: NodeMaterialConnectionPoint;
  57229. /**
  57230. * Gets the rgba component (output)
  57231. */
  57232. readonly rgba: NodeMaterialConnectionPoint;
  57233. /**
  57234. * Gets the rgb component (output)
  57235. */
  57236. readonly rgb: NodeMaterialConnectionPoint;
  57237. protected _buildBlock(state: NodeMaterialBuildState): this;
  57238. }
  57239. }
  57240. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57241. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57242. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57243. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57244. /**
  57245. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57246. */
  57247. export class VectorMergerBlock extends NodeMaterialBlock {
  57248. /**
  57249. * Create a new VectorMergerBlock
  57250. * @param name defines the block name
  57251. */
  57252. constructor(name: string);
  57253. /**
  57254. * Gets the current class name
  57255. * @returns the class name
  57256. */
  57257. getClassName(): string;
  57258. /**
  57259. * Gets the x component (input)
  57260. */
  57261. readonly x: NodeMaterialConnectionPoint;
  57262. /**
  57263. * Gets the y component (input)
  57264. */
  57265. readonly y: NodeMaterialConnectionPoint;
  57266. /**
  57267. * Gets the z component (input)
  57268. */
  57269. readonly z: NodeMaterialConnectionPoint;
  57270. /**
  57271. * Gets the w component (input)
  57272. */
  57273. readonly w: NodeMaterialConnectionPoint;
  57274. /**
  57275. * Gets the xyzw component (output)
  57276. */
  57277. readonly xyzw: NodeMaterialConnectionPoint;
  57278. /**
  57279. * Gets the xyz component (output)
  57280. */
  57281. readonly xyz: NodeMaterialConnectionPoint;
  57282. /**
  57283. * Gets the xy component (output)
  57284. */
  57285. readonly xy: NodeMaterialConnectionPoint;
  57286. protected _buildBlock(state: NodeMaterialBuildState): this;
  57287. }
  57288. }
  57289. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57290. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57291. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57292. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57293. /**
  57294. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57295. */
  57296. export class ColorSplitterBlock extends NodeMaterialBlock {
  57297. /**
  57298. * Create a new ColorSplitterBlock
  57299. * @param name defines the block name
  57300. */
  57301. constructor(name: string);
  57302. /**
  57303. * Gets the current class name
  57304. * @returns the class name
  57305. */
  57306. getClassName(): string;
  57307. /**
  57308. * Gets the rgba component (input)
  57309. */
  57310. readonly rgba: NodeMaterialConnectionPoint;
  57311. /**
  57312. * Gets the rgb component (input)
  57313. */
  57314. readonly rgbIn: NodeMaterialConnectionPoint;
  57315. /**
  57316. * Gets the rgb component (output)
  57317. */
  57318. readonly rgbOut: NodeMaterialConnectionPoint;
  57319. /**
  57320. * Gets the r component (output)
  57321. */
  57322. readonly r: NodeMaterialConnectionPoint;
  57323. /**
  57324. * Gets the g component (output)
  57325. */
  57326. readonly g: NodeMaterialConnectionPoint;
  57327. /**
  57328. * Gets the b component (output)
  57329. */
  57330. readonly b: NodeMaterialConnectionPoint;
  57331. /**
  57332. * Gets the a component (output)
  57333. */
  57334. readonly a: NodeMaterialConnectionPoint;
  57335. protected _inputRename(name: string): string;
  57336. protected _outputRename(name: string): string;
  57337. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57338. }
  57339. }
  57340. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57341. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57342. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57343. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57344. /**
  57345. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57346. */
  57347. export class VectorSplitterBlock extends NodeMaterialBlock {
  57348. /**
  57349. * Create a new VectorSplitterBlock
  57350. * @param name defines the block name
  57351. */
  57352. constructor(name: string);
  57353. /**
  57354. * Gets the current class name
  57355. * @returns the class name
  57356. */
  57357. getClassName(): string;
  57358. /**
  57359. * Gets the xyzw component (input)
  57360. */
  57361. readonly xyzw: NodeMaterialConnectionPoint;
  57362. /**
  57363. * Gets the xyz component (input)
  57364. */
  57365. readonly xyzIn: NodeMaterialConnectionPoint;
  57366. /**
  57367. * Gets the xy component (input)
  57368. */
  57369. readonly xyIn: NodeMaterialConnectionPoint;
  57370. /**
  57371. * Gets the xyz component (output)
  57372. */
  57373. readonly xyzOut: NodeMaterialConnectionPoint;
  57374. /**
  57375. * Gets the xy component (output)
  57376. */
  57377. readonly xyOut: NodeMaterialConnectionPoint;
  57378. /**
  57379. * Gets the x component (output)
  57380. */
  57381. readonly x: NodeMaterialConnectionPoint;
  57382. /**
  57383. * Gets the y component (output)
  57384. */
  57385. readonly y: NodeMaterialConnectionPoint;
  57386. /**
  57387. * Gets the z component (output)
  57388. */
  57389. readonly z: NodeMaterialConnectionPoint;
  57390. /**
  57391. * Gets the w component (output)
  57392. */
  57393. readonly w: NodeMaterialConnectionPoint;
  57394. protected _inputRename(name: string): string;
  57395. protected _outputRename(name: string): string;
  57396. protected _buildBlock(state: NodeMaterialBuildState): this;
  57397. }
  57398. }
  57399. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57400. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57401. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57402. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57403. /**
  57404. * Block used to lerp 2 values
  57405. */
  57406. export class LerpBlock extends NodeMaterialBlock {
  57407. /**
  57408. * Creates a new LerpBlock
  57409. * @param name defines the block name
  57410. */
  57411. constructor(name: string);
  57412. /**
  57413. * Gets the current class name
  57414. * @returns the class name
  57415. */
  57416. getClassName(): string;
  57417. /**
  57418. * Gets the left operand input component
  57419. */
  57420. readonly left: NodeMaterialConnectionPoint;
  57421. /**
  57422. * Gets the right operand input component
  57423. */
  57424. readonly right: NodeMaterialConnectionPoint;
  57425. /**
  57426. * Gets the gradient operand input component
  57427. */
  57428. readonly gradient: NodeMaterialConnectionPoint;
  57429. /**
  57430. * Gets the output component
  57431. */
  57432. readonly output: NodeMaterialConnectionPoint;
  57433. protected _buildBlock(state: NodeMaterialBuildState): this;
  57434. }
  57435. }
  57436. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57437. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57438. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57439. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57440. /**
  57441. * Block used to divide 2 vectors
  57442. */
  57443. export class DivideBlock extends NodeMaterialBlock {
  57444. /**
  57445. * Creates a new DivideBlock
  57446. * @param name defines the block name
  57447. */
  57448. constructor(name: string);
  57449. /**
  57450. * Gets the current class name
  57451. * @returns the class name
  57452. */
  57453. getClassName(): string;
  57454. /**
  57455. * Gets the left operand input component
  57456. */
  57457. readonly left: NodeMaterialConnectionPoint;
  57458. /**
  57459. * Gets the right operand input component
  57460. */
  57461. readonly right: NodeMaterialConnectionPoint;
  57462. /**
  57463. * Gets the output component
  57464. */
  57465. readonly output: NodeMaterialConnectionPoint;
  57466. protected _buildBlock(state: NodeMaterialBuildState): this;
  57467. }
  57468. }
  57469. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57470. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57471. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57472. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57473. /**
  57474. * Block used to subtract 2 vectors
  57475. */
  57476. export class SubtractBlock extends NodeMaterialBlock {
  57477. /**
  57478. * Creates a new SubtractBlock
  57479. * @param name defines the block name
  57480. */
  57481. constructor(name: string);
  57482. /**
  57483. * Gets the current class name
  57484. * @returns the class name
  57485. */
  57486. getClassName(): string;
  57487. /**
  57488. * Gets the left operand input component
  57489. */
  57490. readonly left: NodeMaterialConnectionPoint;
  57491. /**
  57492. * Gets the right operand input component
  57493. */
  57494. readonly right: NodeMaterialConnectionPoint;
  57495. /**
  57496. * Gets the output component
  57497. */
  57498. readonly output: NodeMaterialConnectionPoint;
  57499. protected _buildBlock(state: NodeMaterialBuildState): this;
  57500. }
  57501. }
  57502. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57503. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57504. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57505. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57506. /**
  57507. * Block used to step a value
  57508. */
  57509. export class StepBlock extends NodeMaterialBlock {
  57510. /**
  57511. * Creates a new AddBlock
  57512. * @param name defines the block name
  57513. */
  57514. constructor(name: string);
  57515. /**
  57516. * Gets the current class name
  57517. * @returns the class name
  57518. */
  57519. getClassName(): string;
  57520. /**
  57521. * Gets the value operand input component
  57522. */
  57523. readonly value: NodeMaterialConnectionPoint;
  57524. /**
  57525. * Gets the edge operand input component
  57526. */
  57527. readonly edge: NodeMaterialConnectionPoint;
  57528. /**
  57529. * Gets the output component
  57530. */
  57531. readonly output: NodeMaterialConnectionPoint;
  57532. protected _buildBlock(state: NodeMaterialBuildState): this;
  57533. }
  57534. }
  57535. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57536. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57537. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57538. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57539. /**
  57540. * Block used to get the opposite (1 - x) of a value
  57541. */
  57542. export class OneMinusBlock extends NodeMaterialBlock {
  57543. /**
  57544. * Creates a new OneMinusBlock
  57545. * @param name defines the block name
  57546. */
  57547. constructor(name: string);
  57548. /**
  57549. * Gets the current class name
  57550. * @returns the class name
  57551. */
  57552. getClassName(): string;
  57553. /**
  57554. * Gets the input component
  57555. */
  57556. readonly input: NodeMaterialConnectionPoint;
  57557. /**
  57558. * Gets the output component
  57559. */
  57560. readonly output: NodeMaterialConnectionPoint;
  57561. protected _buildBlock(state: NodeMaterialBuildState): this;
  57562. }
  57563. }
  57564. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57565. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57566. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57567. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57568. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57569. /**
  57570. * Block used to get the view direction
  57571. */
  57572. export class ViewDirectionBlock extends NodeMaterialBlock {
  57573. /**
  57574. * Creates a new ViewDirectionBlock
  57575. * @param name defines the block name
  57576. */
  57577. constructor(name: string);
  57578. /**
  57579. * Gets the current class name
  57580. * @returns the class name
  57581. */
  57582. getClassName(): string;
  57583. /**
  57584. * Gets the world position component
  57585. */
  57586. readonly worldPosition: NodeMaterialConnectionPoint;
  57587. /**
  57588. * Gets the camera position component
  57589. */
  57590. readonly cameraPosition: NodeMaterialConnectionPoint;
  57591. /**
  57592. * Gets the output component
  57593. */
  57594. readonly output: NodeMaterialConnectionPoint;
  57595. autoConfigure(material: NodeMaterial): void;
  57596. protected _buildBlock(state: NodeMaterialBuildState): this;
  57597. }
  57598. }
  57599. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57600. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57601. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57602. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57603. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57604. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57605. /**
  57606. * Block used to compute fresnel value
  57607. */
  57608. export class FresnelBlock extends NodeMaterialBlock {
  57609. /**
  57610. * Create a new FresnelBlock
  57611. * @param name defines the block name
  57612. */
  57613. constructor(name: string);
  57614. /**
  57615. * Gets the current class name
  57616. * @returns the class name
  57617. */
  57618. getClassName(): string;
  57619. /**
  57620. * Gets the world normal input component
  57621. */
  57622. readonly worldNormal: NodeMaterialConnectionPoint;
  57623. /**
  57624. * Gets the view direction input component
  57625. */
  57626. readonly viewDirection: NodeMaterialConnectionPoint;
  57627. /**
  57628. * Gets the bias input component
  57629. */
  57630. readonly bias: NodeMaterialConnectionPoint;
  57631. /**
  57632. * Gets the camera (or eye) position component
  57633. */
  57634. readonly power: NodeMaterialConnectionPoint;
  57635. /**
  57636. * Gets the fresnel output component
  57637. */
  57638. readonly fresnel: NodeMaterialConnectionPoint;
  57639. autoConfigure(material: NodeMaterial): void;
  57640. protected _buildBlock(state: NodeMaterialBuildState): this;
  57641. }
  57642. }
  57643. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57644. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57645. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57646. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57647. /**
  57648. * Block used to get the max of 2 values
  57649. */
  57650. export class MaxBlock extends NodeMaterialBlock {
  57651. /**
  57652. * Creates a new MaxBlock
  57653. * @param name defines the block name
  57654. */
  57655. constructor(name: string);
  57656. /**
  57657. * Gets the current class name
  57658. * @returns the class name
  57659. */
  57660. getClassName(): string;
  57661. /**
  57662. * Gets the left operand input component
  57663. */
  57664. readonly left: NodeMaterialConnectionPoint;
  57665. /**
  57666. * Gets the right operand input component
  57667. */
  57668. readonly right: NodeMaterialConnectionPoint;
  57669. /**
  57670. * Gets the output component
  57671. */
  57672. readonly output: NodeMaterialConnectionPoint;
  57673. protected _buildBlock(state: NodeMaterialBuildState): this;
  57674. }
  57675. }
  57676. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57677. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57678. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57679. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57680. /**
  57681. * Block used to get the min of 2 values
  57682. */
  57683. export class MinBlock extends NodeMaterialBlock {
  57684. /**
  57685. * Creates a new MinBlock
  57686. * @param name defines the block name
  57687. */
  57688. constructor(name: string);
  57689. /**
  57690. * Gets the current class name
  57691. * @returns the class name
  57692. */
  57693. getClassName(): string;
  57694. /**
  57695. * Gets the left operand input component
  57696. */
  57697. readonly left: NodeMaterialConnectionPoint;
  57698. /**
  57699. * Gets the right operand input component
  57700. */
  57701. readonly right: NodeMaterialConnectionPoint;
  57702. /**
  57703. * Gets the output component
  57704. */
  57705. readonly output: NodeMaterialConnectionPoint;
  57706. protected _buildBlock(state: NodeMaterialBuildState): this;
  57707. }
  57708. }
  57709. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57710. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57711. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57712. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57713. /**
  57714. * Block used to get the distance between 2 values
  57715. */
  57716. export class DistanceBlock extends NodeMaterialBlock {
  57717. /**
  57718. * Creates a new DistanceBlock
  57719. * @param name defines the block name
  57720. */
  57721. constructor(name: string);
  57722. /**
  57723. * Gets the current class name
  57724. * @returns the class name
  57725. */
  57726. getClassName(): string;
  57727. /**
  57728. * Gets the left operand input component
  57729. */
  57730. readonly left: NodeMaterialConnectionPoint;
  57731. /**
  57732. * Gets the right operand input component
  57733. */
  57734. readonly right: NodeMaterialConnectionPoint;
  57735. /**
  57736. * Gets the output component
  57737. */
  57738. readonly output: NodeMaterialConnectionPoint;
  57739. protected _buildBlock(state: NodeMaterialBuildState): this;
  57740. }
  57741. }
  57742. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57743. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57744. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57745. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57746. /**
  57747. * Block used to get the length of a vector
  57748. */
  57749. export class LengthBlock extends NodeMaterialBlock {
  57750. /**
  57751. * Creates a new LengthBlock
  57752. * @param name defines the block name
  57753. */
  57754. constructor(name: string);
  57755. /**
  57756. * Gets the current class name
  57757. * @returns the class name
  57758. */
  57759. getClassName(): string;
  57760. /**
  57761. * Gets the value input component
  57762. */
  57763. readonly value: NodeMaterialConnectionPoint;
  57764. /**
  57765. * Gets the output component
  57766. */
  57767. readonly output: NodeMaterialConnectionPoint;
  57768. protected _buildBlock(state: NodeMaterialBuildState): this;
  57769. }
  57770. }
  57771. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57772. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57773. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57774. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57775. /**
  57776. * Block used to get negative version of a value (i.e. x * -1)
  57777. */
  57778. export class NegateBlock extends NodeMaterialBlock {
  57779. /**
  57780. * Creates a new NegateBlock
  57781. * @param name defines the block name
  57782. */
  57783. constructor(name: string);
  57784. /**
  57785. * Gets the current class name
  57786. * @returns the class name
  57787. */
  57788. getClassName(): string;
  57789. /**
  57790. * Gets the value input component
  57791. */
  57792. readonly value: NodeMaterialConnectionPoint;
  57793. /**
  57794. * Gets the output component
  57795. */
  57796. readonly output: NodeMaterialConnectionPoint;
  57797. protected _buildBlock(state: NodeMaterialBuildState): this;
  57798. }
  57799. }
  57800. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57801. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57802. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57803. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57804. /**
  57805. * Block used to get the value of the first parameter raised to the power of the second
  57806. */
  57807. export class PowBlock extends NodeMaterialBlock {
  57808. /**
  57809. * Creates a new PowBlock
  57810. * @param name defines the block name
  57811. */
  57812. constructor(name: string);
  57813. /**
  57814. * Gets the current class name
  57815. * @returns the class name
  57816. */
  57817. getClassName(): string;
  57818. /**
  57819. * Gets the value operand input component
  57820. */
  57821. readonly value: NodeMaterialConnectionPoint;
  57822. /**
  57823. * Gets the power operand input component
  57824. */
  57825. readonly power: NodeMaterialConnectionPoint;
  57826. /**
  57827. * Gets the output component
  57828. */
  57829. readonly output: NodeMaterialConnectionPoint;
  57830. protected _buildBlock(state: NodeMaterialBuildState): this;
  57831. }
  57832. }
  57833. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  57834. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57835. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57836. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57837. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57838. /**
  57839. * Block used to get a random number
  57840. */
  57841. export class RandomNumberBlock extends NodeMaterialBlock {
  57842. /**
  57843. * Creates a new RandomNumberBlock
  57844. * @param name defines the block name
  57845. */
  57846. constructor(name: string);
  57847. /**
  57848. * Gets the current class name
  57849. * @returns the class name
  57850. */
  57851. getClassName(): string;
  57852. /**
  57853. * Gets the seed input component
  57854. */
  57855. readonly seed: NodeMaterialConnectionPoint;
  57856. /**
  57857. * Gets the output component
  57858. */
  57859. readonly output: NodeMaterialConnectionPoint;
  57860. protected _buildBlock(state: NodeMaterialBuildState): this;
  57861. }
  57862. }
  57863. declare module "babylonjs/Materials/Node/Blocks/index" {
  57864. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  57865. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  57866. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  57867. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  57868. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  57869. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  57870. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  57871. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  57872. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  57873. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  57874. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  57875. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  57876. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  57877. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  57878. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  57879. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  57880. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  57881. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  57882. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  57883. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  57884. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  57885. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  57886. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  57887. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  57888. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  57889. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  57890. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  57891. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  57892. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  57893. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  57894. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  57895. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  57896. }
  57897. declare module "babylonjs/Materials/Node/Optimizers/index" {
  57898. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57899. }
  57900. declare module "babylonjs/Materials/Node/index" {
  57901. export * from "babylonjs/Materials/Node/Enums/index";
  57902. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57903. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  57904. export * from "babylonjs/Materials/Node/nodeMaterial";
  57905. export * from "babylonjs/Materials/Node/Blocks/index";
  57906. export * from "babylonjs/Materials/Node/Optimizers/index";
  57907. }
  57908. declare module "babylonjs/Materials/effectRenderer" {
  57909. import { Nullable } from "babylonjs/types";
  57910. import { Texture } from "babylonjs/Materials/Textures/texture";
  57911. import { Engine } from "babylonjs/Engines/engine";
  57912. import { Viewport } from "babylonjs/Maths/math.viewport";
  57913. import { Observable } from "babylonjs/Misc/observable";
  57914. import { Effect } from "babylonjs/Materials/effect";
  57915. import "babylonjs/Shaders/postprocess.vertex";
  57916. /**
  57917. * Effect Render Options
  57918. */
  57919. export interface IEffectRendererOptions {
  57920. /**
  57921. * Defines the vertices positions.
  57922. */
  57923. positions?: number[];
  57924. /**
  57925. * Defines the indices.
  57926. */
  57927. indices?: number[];
  57928. }
  57929. /**
  57930. * Helper class to render one or more effects
  57931. */
  57932. export class EffectRenderer {
  57933. private engine;
  57934. private static _DefaultOptions;
  57935. private _vertexBuffers;
  57936. private _indexBuffer;
  57937. private _ringBufferIndex;
  57938. private _ringScreenBuffer;
  57939. private _fullscreenViewport;
  57940. private _getNextFrameBuffer;
  57941. /**
  57942. * Creates an effect renderer
  57943. * @param engine the engine to use for rendering
  57944. * @param options defines the options of the effect renderer
  57945. */
  57946. constructor(engine: Engine, options?: IEffectRendererOptions);
  57947. /**
  57948. * Sets the current viewport in normalized coordinates 0-1
  57949. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57950. */
  57951. setViewport(viewport?: Viewport): void;
  57952. /**
  57953. * Binds the embedded attributes buffer to the effect.
  57954. * @param effect Defines the effect to bind the attributes for
  57955. */
  57956. bindBuffers(effect: Effect): void;
  57957. /**
  57958. * Sets the current effect wrapper to use during draw.
  57959. * The effect needs to be ready before calling this api.
  57960. * This also sets the default full screen position attribute.
  57961. * @param effectWrapper Defines the effect to draw with
  57962. */
  57963. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57964. /**
  57965. * Draws a full screen quad.
  57966. */
  57967. draw(): void;
  57968. /**
  57969. * renders one or more effects to a specified texture
  57970. * @param effectWrappers list of effects to renderer
  57971. * @param outputTexture texture to draw to, if null it will render to the screen
  57972. */
  57973. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  57974. /**
  57975. * Disposes of the effect renderer
  57976. */
  57977. dispose(): void;
  57978. }
  57979. /**
  57980. * Options to create an EffectWrapper
  57981. */
  57982. interface EffectWrapperCreationOptions {
  57983. /**
  57984. * Engine to use to create the effect
  57985. */
  57986. engine: Engine;
  57987. /**
  57988. * Fragment shader for the effect
  57989. */
  57990. fragmentShader: string;
  57991. /**
  57992. * Vertex shader for the effect
  57993. */
  57994. vertexShader?: string;
  57995. /**
  57996. * Attributes to use in the shader
  57997. */
  57998. attributeNames?: Array<string>;
  57999. /**
  58000. * Uniforms to use in the shader
  58001. */
  58002. uniformNames?: Array<string>;
  58003. /**
  58004. * Texture sampler names to use in the shader
  58005. */
  58006. samplerNames?: Array<string>;
  58007. /**
  58008. * The friendly name of the effect displayed in Spector.
  58009. */
  58010. name?: string;
  58011. }
  58012. /**
  58013. * Wraps an effect to be used for rendering
  58014. */
  58015. export class EffectWrapper {
  58016. /**
  58017. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58018. */
  58019. onApplyObservable: Observable<{}>;
  58020. /**
  58021. * The underlying effect
  58022. */
  58023. effect: Effect;
  58024. /**
  58025. * Creates an effect to be renderer
  58026. * @param creationOptions options to create the effect
  58027. */
  58028. constructor(creationOptions: EffectWrapperCreationOptions);
  58029. /**
  58030. * Disposes of the effect wrapper
  58031. */
  58032. dispose(): void;
  58033. }
  58034. }
  58035. declare module "babylonjs/Materials/index" {
  58036. export * from "babylonjs/Materials/Background/index";
  58037. export * from "babylonjs/Materials/colorCurves";
  58038. export * from "babylonjs/Materials/iEffectFallbacks";
  58039. export * from "babylonjs/Materials/effectFallbacks";
  58040. export * from "babylonjs/Materials/effect";
  58041. export * from "babylonjs/Materials/fresnelParameters";
  58042. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58043. export * from "babylonjs/Materials/material";
  58044. export * from "babylonjs/Materials/materialDefines";
  58045. export * from "babylonjs/Materials/materialHelper";
  58046. export * from "babylonjs/Materials/multiMaterial";
  58047. export * from "babylonjs/Materials/PBR/index";
  58048. export * from "babylonjs/Materials/pushMaterial";
  58049. export * from "babylonjs/Materials/shaderMaterial";
  58050. export * from "babylonjs/Materials/standardMaterial";
  58051. export * from "babylonjs/Materials/Textures/index";
  58052. export * from "babylonjs/Materials/uniformBuffer";
  58053. export * from "babylonjs/Materials/materialFlags";
  58054. export * from "babylonjs/Materials/Node/index";
  58055. export * from "babylonjs/Materials/effectRenderer";
  58056. }
  58057. declare module "babylonjs/Maths/index" {
  58058. export * from "babylonjs/Maths/math.scalar";
  58059. export * from "babylonjs/Maths/math";
  58060. export * from "babylonjs/Maths/sphericalPolynomial";
  58061. }
  58062. declare module "babylonjs/Misc/workerPool" {
  58063. import { IDisposable } from "babylonjs/scene";
  58064. /**
  58065. * Helper class to push actions to a pool of workers.
  58066. */
  58067. export class WorkerPool implements IDisposable {
  58068. private _workerInfos;
  58069. private _pendingActions;
  58070. /**
  58071. * Constructor
  58072. * @param workers Array of workers to use for actions
  58073. */
  58074. constructor(workers: Array<Worker>);
  58075. /**
  58076. * Terminates all workers and clears any pending actions.
  58077. */
  58078. dispose(): void;
  58079. /**
  58080. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58081. * pended until a worker has completed its action.
  58082. * @param action The action to perform. Call onComplete when the action is complete.
  58083. */
  58084. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58085. private _execute;
  58086. }
  58087. }
  58088. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  58089. import { IDisposable } from "babylonjs/scene";
  58090. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58091. /**
  58092. * Configuration for Draco compression
  58093. */
  58094. export interface IDracoCompressionConfiguration {
  58095. /**
  58096. * Configuration for the decoder.
  58097. */
  58098. decoder: {
  58099. /**
  58100. * The url to the WebAssembly module.
  58101. */
  58102. wasmUrl?: string;
  58103. /**
  58104. * The url to the WebAssembly binary.
  58105. */
  58106. wasmBinaryUrl?: string;
  58107. /**
  58108. * The url to the fallback JavaScript module.
  58109. */
  58110. fallbackUrl?: string;
  58111. };
  58112. }
  58113. /**
  58114. * Draco compression (https://google.github.io/draco/)
  58115. *
  58116. * This class wraps the Draco module.
  58117. *
  58118. * **Encoder**
  58119. *
  58120. * The encoder is not currently implemented.
  58121. *
  58122. * **Decoder**
  58123. *
  58124. * 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.
  58125. *
  58126. * To update the configuration, use the following code:
  58127. * ```javascript
  58128. * DracoCompression.Configuration = {
  58129. * decoder: {
  58130. * wasmUrl: "<url to the WebAssembly library>",
  58131. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58132. * fallbackUrl: "<url to the fallback JavaScript library>",
  58133. * }
  58134. * };
  58135. * ```
  58136. *
  58137. * 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.
  58138. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58139. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58140. *
  58141. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58142. * ```javascript
  58143. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58144. * ```
  58145. *
  58146. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58147. */
  58148. export class DracoCompression implements IDisposable {
  58149. private _workerPoolPromise?;
  58150. private _decoderModulePromise?;
  58151. /**
  58152. * The configuration. Defaults to the following urls:
  58153. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58154. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58155. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58156. */
  58157. static Configuration: IDracoCompressionConfiguration;
  58158. /**
  58159. * Returns true if the decoder configuration is available.
  58160. */
  58161. static readonly DecoderAvailable: boolean;
  58162. /**
  58163. * Default number of workers to create when creating the draco compression object.
  58164. */
  58165. static DefaultNumWorkers: number;
  58166. private static GetDefaultNumWorkers;
  58167. private static _Default;
  58168. /**
  58169. * Default instance for the draco compression object.
  58170. */
  58171. static readonly Default: DracoCompression;
  58172. /**
  58173. * Constructor
  58174. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58175. */
  58176. constructor(numWorkers?: number);
  58177. /**
  58178. * Stop all async operations and release resources.
  58179. */
  58180. dispose(): void;
  58181. /**
  58182. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58183. * @returns a promise that resolves when ready
  58184. */
  58185. whenReadyAsync(): Promise<void>;
  58186. /**
  58187. * Decode Draco compressed mesh data to vertex data.
  58188. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58189. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58190. * @returns A promise that resolves with the decoded vertex data
  58191. */
  58192. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58193. [kind: string]: number;
  58194. }): Promise<VertexData>;
  58195. }
  58196. }
  58197. declare module "babylonjs/Meshes/Compression/index" {
  58198. export * from "babylonjs/Meshes/Compression/dracoCompression";
  58199. }
  58200. declare module "babylonjs/Meshes/csg" {
  58201. import { Nullable } from "babylonjs/types";
  58202. import { Scene } from "babylonjs/scene";
  58203. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58204. import { Mesh } from "babylonjs/Meshes/mesh";
  58205. import { Material } from "babylonjs/Materials/material";
  58206. /**
  58207. * Class for building Constructive Solid Geometry
  58208. */
  58209. export class CSG {
  58210. private polygons;
  58211. /**
  58212. * The world matrix
  58213. */
  58214. matrix: Matrix;
  58215. /**
  58216. * Stores the position
  58217. */
  58218. position: Vector3;
  58219. /**
  58220. * Stores the rotation
  58221. */
  58222. rotation: Vector3;
  58223. /**
  58224. * Stores the rotation quaternion
  58225. */
  58226. rotationQuaternion: Nullable<Quaternion>;
  58227. /**
  58228. * Stores the scaling vector
  58229. */
  58230. scaling: Vector3;
  58231. /**
  58232. * Convert the Mesh to CSG
  58233. * @param mesh The Mesh to convert to CSG
  58234. * @returns A new CSG from the Mesh
  58235. */
  58236. static FromMesh(mesh: Mesh): CSG;
  58237. /**
  58238. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58239. * @param polygons Polygons used to construct a CSG solid
  58240. */
  58241. private static FromPolygons;
  58242. /**
  58243. * Clones, or makes a deep copy, of the CSG
  58244. * @returns A new CSG
  58245. */
  58246. clone(): CSG;
  58247. /**
  58248. * Unions this CSG with another CSG
  58249. * @param csg The CSG to union against this CSG
  58250. * @returns The unioned CSG
  58251. */
  58252. union(csg: CSG): CSG;
  58253. /**
  58254. * Unions this CSG with another CSG in place
  58255. * @param csg The CSG to union against this CSG
  58256. */
  58257. unionInPlace(csg: CSG): void;
  58258. /**
  58259. * Subtracts this CSG with another CSG
  58260. * @param csg The CSG to subtract against this CSG
  58261. * @returns A new CSG
  58262. */
  58263. subtract(csg: CSG): CSG;
  58264. /**
  58265. * Subtracts this CSG with another CSG in place
  58266. * @param csg The CSG to subtact against this CSG
  58267. */
  58268. subtractInPlace(csg: CSG): void;
  58269. /**
  58270. * Intersect this CSG with another CSG
  58271. * @param csg The CSG to intersect against this CSG
  58272. * @returns A new CSG
  58273. */
  58274. intersect(csg: CSG): CSG;
  58275. /**
  58276. * Intersects this CSG with another CSG in place
  58277. * @param csg The CSG to intersect against this CSG
  58278. */
  58279. intersectInPlace(csg: CSG): void;
  58280. /**
  58281. * Return a new CSG solid with solid and empty space switched. This solid is
  58282. * not modified.
  58283. * @returns A new CSG solid with solid and empty space switched
  58284. */
  58285. inverse(): CSG;
  58286. /**
  58287. * Inverses the CSG in place
  58288. */
  58289. inverseInPlace(): void;
  58290. /**
  58291. * This is used to keep meshes transformations so they can be restored
  58292. * when we build back a Babylon Mesh
  58293. * NB : All CSG operations are performed in world coordinates
  58294. * @param csg The CSG to copy the transform attributes from
  58295. * @returns This CSG
  58296. */
  58297. copyTransformAttributes(csg: CSG): CSG;
  58298. /**
  58299. * Build Raw mesh from CSG
  58300. * Coordinates here are in world space
  58301. * @param name The name of the mesh geometry
  58302. * @param scene The Scene
  58303. * @param keepSubMeshes Specifies if the submeshes should be kept
  58304. * @returns A new Mesh
  58305. */
  58306. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58307. /**
  58308. * Build Mesh from CSG taking material and transforms into account
  58309. * @param name The name of the Mesh
  58310. * @param material The material of the Mesh
  58311. * @param scene The Scene
  58312. * @param keepSubMeshes Specifies if submeshes should be kept
  58313. * @returns The new Mesh
  58314. */
  58315. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58316. }
  58317. }
  58318. declare module "babylonjs/Meshes/trailMesh" {
  58319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58320. import { Mesh } from "babylonjs/Meshes/mesh";
  58321. import { Scene } from "babylonjs/scene";
  58322. /**
  58323. * Class used to create a trail following a mesh
  58324. */
  58325. export class TrailMesh extends Mesh {
  58326. private _generator;
  58327. private _autoStart;
  58328. private _running;
  58329. private _diameter;
  58330. private _length;
  58331. private _sectionPolygonPointsCount;
  58332. private _sectionVectors;
  58333. private _sectionNormalVectors;
  58334. private _beforeRenderObserver;
  58335. /**
  58336. * @constructor
  58337. * @param name The value used by scene.getMeshByName() to do a lookup.
  58338. * @param generator The mesh to generate a trail.
  58339. * @param scene The scene to add this mesh to.
  58340. * @param diameter Diameter of trailing mesh. Default is 1.
  58341. * @param length Length of trailing mesh. Default is 60.
  58342. * @param autoStart Automatically start trailing mesh. Default true.
  58343. */
  58344. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58345. /**
  58346. * "TrailMesh"
  58347. * @returns "TrailMesh"
  58348. */
  58349. getClassName(): string;
  58350. private _createMesh;
  58351. /**
  58352. * Start trailing mesh.
  58353. */
  58354. start(): void;
  58355. /**
  58356. * Stop trailing mesh.
  58357. */
  58358. stop(): void;
  58359. /**
  58360. * Update trailing mesh geometry.
  58361. */
  58362. update(): void;
  58363. /**
  58364. * Returns a new TrailMesh object.
  58365. * @param name is a string, the name given to the new mesh
  58366. * @param newGenerator use new generator object for cloned trail mesh
  58367. * @returns a new mesh
  58368. */
  58369. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58370. /**
  58371. * Serializes this trail mesh
  58372. * @param serializationObject object to write serialization to
  58373. */
  58374. serialize(serializationObject: any): void;
  58375. /**
  58376. * Parses a serialized trail mesh
  58377. * @param parsedMesh the serialized mesh
  58378. * @param scene the scene to create the trail mesh in
  58379. * @returns the created trail mesh
  58380. */
  58381. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58382. }
  58383. }
  58384. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  58385. import { Nullable } from "babylonjs/types";
  58386. import { Scene } from "babylonjs/scene";
  58387. import { Vector4 } from "babylonjs/Maths/math.vector";
  58388. import { Color4 } from "babylonjs/Maths/math.color";
  58389. import { Mesh } from "babylonjs/Meshes/mesh";
  58390. /**
  58391. * Class containing static functions to help procedurally build meshes
  58392. */
  58393. export class TiledBoxBuilder {
  58394. /**
  58395. * Creates a box mesh
  58396. * 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)
  58397. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58399. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58401. * @param name defines the name of the mesh
  58402. * @param options defines the options used to create the mesh
  58403. * @param scene defines the hosting scene
  58404. * @returns the box mesh
  58405. */
  58406. static CreateTiledBox(name: string, options: {
  58407. pattern?: number;
  58408. width?: number;
  58409. height?: number;
  58410. depth?: number;
  58411. tileSize?: number;
  58412. tileWidth?: number;
  58413. tileHeight?: number;
  58414. alignHorizontal?: number;
  58415. alignVertical?: number;
  58416. faceUV?: Vector4[];
  58417. faceColors?: Color4[];
  58418. sideOrientation?: number;
  58419. updatable?: boolean;
  58420. }, scene?: Nullable<Scene>): Mesh;
  58421. }
  58422. }
  58423. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  58424. import { Vector4 } from "babylonjs/Maths/math.vector";
  58425. import { Mesh } from "babylonjs/Meshes/mesh";
  58426. /**
  58427. * Class containing static functions to help procedurally build meshes
  58428. */
  58429. export class TorusKnotBuilder {
  58430. /**
  58431. * Creates a torus knot mesh
  58432. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58433. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58434. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58435. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58437. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58439. * @param name defines the name of the mesh
  58440. * @param options defines the options used to create the mesh
  58441. * @param scene defines the hosting scene
  58442. * @returns the torus knot mesh
  58443. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58444. */
  58445. static CreateTorusKnot(name: string, options: {
  58446. radius?: number;
  58447. tube?: number;
  58448. radialSegments?: number;
  58449. tubularSegments?: number;
  58450. p?: number;
  58451. q?: number;
  58452. updatable?: boolean;
  58453. sideOrientation?: number;
  58454. frontUVs?: Vector4;
  58455. backUVs?: Vector4;
  58456. }, scene: any): Mesh;
  58457. }
  58458. }
  58459. declare module "babylonjs/Meshes/polygonMesh" {
  58460. import { Scene } from "babylonjs/scene";
  58461. import { Vector2 } from "babylonjs/Maths/math.vector";
  58462. import { Mesh } from "babylonjs/Meshes/mesh";
  58463. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58464. import { Path2 } from "babylonjs/Maths/math.path";
  58465. /**
  58466. * Polygon
  58467. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58468. */
  58469. export class Polygon {
  58470. /**
  58471. * Creates a rectangle
  58472. * @param xmin bottom X coord
  58473. * @param ymin bottom Y coord
  58474. * @param xmax top X coord
  58475. * @param ymax top Y coord
  58476. * @returns points that make the resulting rectation
  58477. */
  58478. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58479. /**
  58480. * Creates a circle
  58481. * @param radius radius of circle
  58482. * @param cx scale in x
  58483. * @param cy scale in y
  58484. * @param numberOfSides number of sides that make up the circle
  58485. * @returns points that make the resulting circle
  58486. */
  58487. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58488. /**
  58489. * Creates a polygon from input string
  58490. * @param input Input polygon data
  58491. * @returns the parsed points
  58492. */
  58493. static Parse(input: string): Vector2[];
  58494. /**
  58495. * Starts building a polygon from x and y coordinates
  58496. * @param x x coordinate
  58497. * @param y y coordinate
  58498. * @returns the started path2
  58499. */
  58500. static StartingAt(x: number, y: number): Path2;
  58501. }
  58502. /**
  58503. * Builds a polygon
  58504. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58505. */
  58506. export class PolygonMeshBuilder {
  58507. private _points;
  58508. private _outlinepoints;
  58509. private _holes;
  58510. private _name;
  58511. private _scene;
  58512. private _epoints;
  58513. private _eholes;
  58514. private _addToepoint;
  58515. /**
  58516. * Babylon reference to the earcut plugin.
  58517. */
  58518. bjsEarcut: any;
  58519. /**
  58520. * Creates a PolygonMeshBuilder
  58521. * @param name name of the builder
  58522. * @param contours Path of the polygon
  58523. * @param scene scene to add to when creating the mesh
  58524. * @param earcutInjection can be used to inject your own earcut reference
  58525. */
  58526. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58527. /**
  58528. * Adds a whole within the polygon
  58529. * @param hole Array of points defining the hole
  58530. * @returns this
  58531. */
  58532. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58533. /**
  58534. * Creates the polygon
  58535. * @param updatable If the mesh should be updatable
  58536. * @param depth The depth of the mesh created
  58537. * @returns the created mesh
  58538. */
  58539. build(updatable?: boolean, depth?: number): Mesh;
  58540. /**
  58541. * Creates the polygon
  58542. * @param depth The depth of the mesh created
  58543. * @returns the created VertexData
  58544. */
  58545. buildVertexData(depth?: number): VertexData;
  58546. /**
  58547. * Adds a side to the polygon
  58548. * @param positions points that make the polygon
  58549. * @param normals normals of the polygon
  58550. * @param uvs uvs of the polygon
  58551. * @param indices indices of the polygon
  58552. * @param bounds bounds of the polygon
  58553. * @param points points of the polygon
  58554. * @param depth depth of the polygon
  58555. * @param flip flip of the polygon
  58556. */
  58557. private addSide;
  58558. }
  58559. }
  58560. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  58561. import { Scene } from "babylonjs/scene";
  58562. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58563. import { Color4 } from "babylonjs/Maths/math.color";
  58564. import { Mesh } from "babylonjs/Meshes/mesh";
  58565. import { Nullable } from "babylonjs/types";
  58566. /**
  58567. * Class containing static functions to help procedurally build meshes
  58568. */
  58569. export class PolygonBuilder {
  58570. /**
  58571. * Creates a polygon mesh
  58572. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58573. * * 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
  58574. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58576. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58577. * * Remember you can only change the shape positions, not their number when updating a polygon
  58578. * @param name defines the name of the mesh
  58579. * @param options defines the options used to create the mesh
  58580. * @param scene defines the hosting scene
  58581. * @param earcutInjection can be used to inject your own earcut reference
  58582. * @returns the polygon mesh
  58583. */
  58584. static CreatePolygon(name: string, options: {
  58585. shape: Vector3[];
  58586. holes?: Vector3[][];
  58587. depth?: number;
  58588. faceUV?: Vector4[];
  58589. faceColors?: Color4[];
  58590. updatable?: boolean;
  58591. sideOrientation?: number;
  58592. frontUVs?: Vector4;
  58593. backUVs?: Vector4;
  58594. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58595. /**
  58596. * Creates an extruded polygon mesh, with depth in the Y direction.
  58597. * * 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)
  58598. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58599. * @param name defines the name of the mesh
  58600. * @param options defines the options used to create the mesh
  58601. * @param scene defines the hosting scene
  58602. * @param earcutInjection can be used to inject your own earcut reference
  58603. * @returns the polygon mesh
  58604. */
  58605. static ExtrudePolygon(name: string, options: {
  58606. shape: Vector3[];
  58607. holes?: Vector3[][];
  58608. depth?: number;
  58609. faceUV?: Vector4[];
  58610. faceColors?: Color4[];
  58611. updatable?: boolean;
  58612. sideOrientation?: number;
  58613. frontUVs?: Vector4;
  58614. backUVs?: Vector4;
  58615. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58616. }
  58617. }
  58618. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  58619. import { Scene } from "babylonjs/scene";
  58620. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58621. import { Mesh } from "babylonjs/Meshes/mesh";
  58622. import { Nullable } from "babylonjs/types";
  58623. /**
  58624. * Class containing static functions to help procedurally build meshes
  58625. */
  58626. export class LatheBuilder {
  58627. /**
  58628. * Creates lathe mesh.
  58629. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58630. * * 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
  58631. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58632. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58633. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58634. * * 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
  58635. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58636. * * 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
  58637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58639. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58641. * @param name defines the name of the mesh
  58642. * @param options defines the options used to create the mesh
  58643. * @param scene defines the hosting scene
  58644. * @returns the lathe mesh
  58645. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58646. */
  58647. static CreateLathe(name: string, options: {
  58648. shape: Vector3[];
  58649. radius?: number;
  58650. tessellation?: number;
  58651. clip?: number;
  58652. arc?: number;
  58653. closed?: boolean;
  58654. updatable?: boolean;
  58655. sideOrientation?: number;
  58656. frontUVs?: Vector4;
  58657. backUVs?: Vector4;
  58658. cap?: number;
  58659. invertUV?: boolean;
  58660. }, scene?: Nullable<Scene>): Mesh;
  58661. }
  58662. }
  58663. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  58664. import { Nullable } from "babylonjs/types";
  58665. import { Scene } from "babylonjs/scene";
  58666. import { Vector4 } from "babylonjs/Maths/math.vector";
  58667. import { Mesh } from "babylonjs/Meshes/mesh";
  58668. /**
  58669. * Class containing static functions to help procedurally build meshes
  58670. */
  58671. export class TiledPlaneBuilder {
  58672. /**
  58673. * Creates a tiled plane mesh
  58674. * * The parameter `pattern` will, depending on value, do nothing or
  58675. * * * flip (reflect about central vertical) alternate tiles across and up
  58676. * * * flip every tile on alternate rows
  58677. * * * rotate (180 degs) alternate tiles across and up
  58678. * * * rotate every tile on alternate rows
  58679. * * * flip and rotate alternate tiles across and up
  58680. * * * flip and rotate every tile on alternate rows
  58681. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  58682. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  58683. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58684. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58685. * * 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)
  58686. * * 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)
  58687. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58688. * @param name defines the name of the mesh
  58689. * @param options defines the options used to create the mesh
  58690. * @param scene defines the hosting scene
  58691. * @returns the box mesh
  58692. */
  58693. static CreateTiledPlane(name: string, options: {
  58694. pattern?: number;
  58695. tileSize?: number;
  58696. tileWidth?: number;
  58697. tileHeight?: number;
  58698. size?: number;
  58699. width?: number;
  58700. height?: number;
  58701. alignHorizontal?: number;
  58702. alignVertical?: number;
  58703. sideOrientation?: number;
  58704. frontUVs?: Vector4;
  58705. backUVs?: Vector4;
  58706. updatable?: boolean;
  58707. }, scene?: Nullable<Scene>): Mesh;
  58708. }
  58709. }
  58710. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  58711. import { Nullable } from "babylonjs/types";
  58712. import { Scene } from "babylonjs/scene";
  58713. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58714. import { Mesh } from "babylonjs/Meshes/mesh";
  58715. /**
  58716. * Class containing static functions to help procedurally build meshes
  58717. */
  58718. export class TubeBuilder {
  58719. /**
  58720. * Creates a tube mesh.
  58721. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58722. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58723. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58724. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58725. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58726. * * 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)
  58727. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58728. * * 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
  58729. * * 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
  58730. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58731. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58732. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58734. * @param name defines the name of the mesh
  58735. * @param options defines the options used to create the mesh
  58736. * @param scene defines the hosting scene
  58737. * @returns the tube mesh
  58738. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58739. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58740. */
  58741. static CreateTube(name: string, options: {
  58742. path: Vector3[];
  58743. radius?: number;
  58744. tessellation?: number;
  58745. radiusFunction?: {
  58746. (i: number, distance: number): number;
  58747. };
  58748. cap?: number;
  58749. arc?: number;
  58750. updatable?: boolean;
  58751. sideOrientation?: number;
  58752. frontUVs?: Vector4;
  58753. backUVs?: Vector4;
  58754. instance?: Mesh;
  58755. invertUV?: boolean;
  58756. }, scene?: Nullable<Scene>): Mesh;
  58757. }
  58758. }
  58759. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  58760. import { Scene } from "babylonjs/scene";
  58761. import { Vector4 } from "babylonjs/Maths/math.vector";
  58762. import { Mesh } from "babylonjs/Meshes/mesh";
  58763. import { Nullable } from "babylonjs/types";
  58764. /**
  58765. * Class containing static functions to help procedurally build meshes
  58766. */
  58767. export class IcoSphereBuilder {
  58768. /**
  58769. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58770. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58771. * * 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`)
  58772. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58773. * * 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
  58774. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58775. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58777. * @param name defines the name of the mesh
  58778. * @param options defines the options used to create the mesh
  58779. * @param scene defines the hosting scene
  58780. * @returns the icosahedron mesh
  58781. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58782. */
  58783. static CreateIcoSphere(name: string, options: {
  58784. radius?: number;
  58785. radiusX?: number;
  58786. radiusY?: number;
  58787. radiusZ?: number;
  58788. flat?: boolean;
  58789. subdivisions?: number;
  58790. sideOrientation?: number;
  58791. frontUVs?: Vector4;
  58792. backUVs?: Vector4;
  58793. updatable?: boolean;
  58794. }, scene?: Nullable<Scene>): Mesh;
  58795. }
  58796. }
  58797. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  58798. import { Vector3 } from "babylonjs/Maths/math.vector";
  58799. import { Mesh } from "babylonjs/Meshes/mesh";
  58800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58801. /**
  58802. * Class containing static functions to help procedurally build meshes
  58803. */
  58804. export class DecalBuilder {
  58805. /**
  58806. * Creates a decal mesh.
  58807. * 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
  58808. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58809. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58810. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58811. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58812. * @param name defines the name of the mesh
  58813. * @param sourceMesh defines the mesh where the decal must be applied
  58814. * @param options defines the options used to create the mesh
  58815. * @param scene defines the hosting scene
  58816. * @returns the decal mesh
  58817. * @see https://doc.babylonjs.com/how_to/decals
  58818. */
  58819. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58820. position?: Vector3;
  58821. normal?: Vector3;
  58822. size?: Vector3;
  58823. angle?: number;
  58824. }): Mesh;
  58825. }
  58826. }
  58827. declare module "babylonjs/Meshes/meshBuilder" {
  58828. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  58829. import { Nullable } from "babylonjs/types";
  58830. import { Scene } from "babylonjs/scene";
  58831. import { Mesh } from "babylonjs/Meshes/mesh";
  58832. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  58833. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  58834. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58835. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58836. import { Plane } from "babylonjs/Maths/math.plane";
  58837. /**
  58838. * Class containing static functions to help procedurally build meshes
  58839. */
  58840. export class MeshBuilder {
  58841. /**
  58842. * Creates a box mesh
  58843. * * The parameter `size` sets the size (float) of each box side (default 1)
  58844. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  58845. * * 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)
  58846. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58848. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58850. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58851. * @param name defines the name of the mesh
  58852. * @param options defines the options used to create the mesh
  58853. * @param scene defines the hosting scene
  58854. * @returns the box mesh
  58855. */
  58856. static CreateBox(name: string, options: {
  58857. size?: number;
  58858. width?: number;
  58859. height?: number;
  58860. depth?: number;
  58861. faceUV?: Vector4[];
  58862. faceColors?: Color4[];
  58863. sideOrientation?: number;
  58864. frontUVs?: Vector4;
  58865. backUVs?: Vector4;
  58866. updatable?: boolean;
  58867. }, scene?: Nullable<Scene>): Mesh;
  58868. /**
  58869. * Creates a tiled box mesh
  58870. * * faceTiles sets the pattern, tile size and number of tiles for a face
  58871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58872. * @param name defines the name of the mesh
  58873. * @param options defines the options used to create the mesh
  58874. * @param scene defines the hosting scene
  58875. * @returns the tiled box mesh
  58876. */
  58877. static CreateTiledBox(name: string, options: {
  58878. pattern?: number;
  58879. size?: number;
  58880. width?: number;
  58881. height?: number;
  58882. depth: number;
  58883. tileSize?: number;
  58884. tileWidth?: number;
  58885. tileHeight?: number;
  58886. faceUV?: Vector4[];
  58887. faceColors?: Color4[];
  58888. alignHorizontal?: number;
  58889. alignVertical?: number;
  58890. sideOrientation?: number;
  58891. updatable?: boolean;
  58892. }, scene?: Nullable<Scene>): Mesh;
  58893. /**
  58894. * Creates a sphere mesh
  58895. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  58896. * * 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`)
  58897. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  58898. * * 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
  58899. * * 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)
  58900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58901. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58903. * @param name defines the name of the mesh
  58904. * @param options defines the options used to create the mesh
  58905. * @param scene defines the hosting scene
  58906. * @returns the sphere mesh
  58907. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  58908. */
  58909. static CreateSphere(name: string, options: {
  58910. segments?: number;
  58911. diameter?: number;
  58912. diameterX?: number;
  58913. diameterY?: number;
  58914. diameterZ?: number;
  58915. arc?: number;
  58916. slice?: number;
  58917. sideOrientation?: number;
  58918. frontUVs?: Vector4;
  58919. backUVs?: Vector4;
  58920. updatable?: boolean;
  58921. }, scene?: Nullable<Scene>): Mesh;
  58922. /**
  58923. * Creates a plane polygonal mesh. By default, this is a disc
  58924. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  58925. * * 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
  58926. * * 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
  58927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58928. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58930. * @param name defines the name of the mesh
  58931. * @param options defines the options used to create the mesh
  58932. * @param scene defines the hosting scene
  58933. * @returns the plane polygonal mesh
  58934. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  58935. */
  58936. static CreateDisc(name: string, options: {
  58937. radius?: number;
  58938. tessellation?: number;
  58939. arc?: number;
  58940. updatable?: boolean;
  58941. sideOrientation?: number;
  58942. frontUVs?: Vector4;
  58943. backUVs?: Vector4;
  58944. }, scene?: Nullable<Scene>): Mesh;
  58945. /**
  58946. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58947. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58948. * * 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`)
  58949. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58950. * * 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
  58951. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58952. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58954. * @param name defines the name of the mesh
  58955. * @param options defines the options used to create the mesh
  58956. * @param scene defines the hosting scene
  58957. * @returns the icosahedron mesh
  58958. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58959. */
  58960. static CreateIcoSphere(name: string, options: {
  58961. radius?: number;
  58962. radiusX?: number;
  58963. radiusY?: number;
  58964. radiusZ?: number;
  58965. flat?: boolean;
  58966. subdivisions?: number;
  58967. sideOrientation?: number;
  58968. frontUVs?: Vector4;
  58969. backUVs?: Vector4;
  58970. updatable?: boolean;
  58971. }, scene?: Nullable<Scene>): Mesh;
  58972. /**
  58973. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58974. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58975. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58976. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58977. * * 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
  58978. * * 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
  58979. * * 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
  58980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58981. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58982. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58983. * * 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
  58984. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58985. * * 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
  58986. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58988. * @param name defines the name of the mesh
  58989. * @param options defines the options used to create the mesh
  58990. * @param scene defines the hosting scene
  58991. * @returns the ribbon mesh
  58992. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58993. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58994. */
  58995. static CreateRibbon(name: string, options: {
  58996. pathArray: Vector3[][];
  58997. closeArray?: boolean;
  58998. closePath?: boolean;
  58999. offset?: number;
  59000. updatable?: boolean;
  59001. sideOrientation?: number;
  59002. frontUVs?: Vector4;
  59003. backUVs?: Vector4;
  59004. instance?: Mesh;
  59005. invertUV?: boolean;
  59006. uvs?: Vector2[];
  59007. colors?: Color4[];
  59008. }, scene?: Nullable<Scene>): Mesh;
  59009. /**
  59010. * Creates a cylinder or a cone mesh
  59011. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59012. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59013. * * 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.
  59014. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59015. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59016. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59017. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59018. * * 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).
  59019. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59020. * * 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).
  59021. * * 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
  59022. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59023. * * 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
  59024. * * 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.
  59025. * * If `enclose` is false, a ring surface is one element.
  59026. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59027. * * 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
  59028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59029. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59031. * @param name defines the name of the mesh
  59032. * @param options defines the options used to create the mesh
  59033. * @param scene defines the hosting scene
  59034. * @returns the cylinder mesh
  59035. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59036. */
  59037. static CreateCylinder(name: string, options: {
  59038. height?: number;
  59039. diameterTop?: number;
  59040. diameterBottom?: number;
  59041. diameter?: number;
  59042. tessellation?: number;
  59043. subdivisions?: number;
  59044. arc?: number;
  59045. faceColors?: Color4[];
  59046. faceUV?: Vector4[];
  59047. updatable?: boolean;
  59048. hasRings?: boolean;
  59049. enclose?: boolean;
  59050. cap?: number;
  59051. sideOrientation?: number;
  59052. frontUVs?: Vector4;
  59053. backUVs?: Vector4;
  59054. }, scene?: Nullable<Scene>): Mesh;
  59055. /**
  59056. * Creates a torus mesh
  59057. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59058. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59059. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59061. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59063. * @param name defines the name of the mesh
  59064. * @param options defines the options used to create the mesh
  59065. * @param scene defines the hosting scene
  59066. * @returns the torus mesh
  59067. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59068. */
  59069. static CreateTorus(name: string, options: {
  59070. diameter?: number;
  59071. thickness?: number;
  59072. tessellation?: number;
  59073. updatable?: boolean;
  59074. sideOrientation?: number;
  59075. frontUVs?: Vector4;
  59076. backUVs?: Vector4;
  59077. }, scene?: Nullable<Scene>): Mesh;
  59078. /**
  59079. * Creates a torus knot mesh
  59080. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59081. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59082. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59083. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59085. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59087. * @param name defines the name of the mesh
  59088. * @param options defines the options used to create the mesh
  59089. * @param scene defines the hosting scene
  59090. * @returns the torus knot mesh
  59091. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59092. */
  59093. static CreateTorusKnot(name: string, options: {
  59094. radius?: number;
  59095. tube?: number;
  59096. radialSegments?: number;
  59097. tubularSegments?: number;
  59098. p?: number;
  59099. q?: number;
  59100. updatable?: boolean;
  59101. sideOrientation?: number;
  59102. frontUVs?: Vector4;
  59103. backUVs?: Vector4;
  59104. }, scene?: Nullable<Scene>): Mesh;
  59105. /**
  59106. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59107. * * 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
  59108. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59109. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59110. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59111. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59112. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59113. * * 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
  59114. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59116. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59117. * @param name defines the name of the new line system
  59118. * @param options defines the options used to create the line system
  59119. * @param scene defines the hosting scene
  59120. * @returns a new line system mesh
  59121. */
  59122. static CreateLineSystem(name: string, options: {
  59123. lines: Vector3[][];
  59124. updatable?: boolean;
  59125. instance?: Nullable<LinesMesh>;
  59126. colors?: Nullable<Color4[][]>;
  59127. useVertexAlpha?: boolean;
  59128. }, scene: Nullable<Scene>): LinesMesh;
  59129. /**
  59130. * Creates a line mesh
  59131. * 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
  59132. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59133. * * The parameter `points` is an array successive Vector3
  59134. * * 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
  59135. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59136. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59137. * * When updating an instance, remember that only point positions can change, not the number of points
  59138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59139. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59140. * @param name defines the name of the new line system
  59141. * @param options defines the options used to create the line system
  59142. * @param scene defines the hosting scene
  59143. * @returns a new line mesh
  59144. */
  59145. static CreateLines(name: string, options: {
  59146. points: Vector3[];
  59147. updatable?: boolean;
  59148. instance?: Nullable<LinesMesh>;
  59149. colors?: Color4[];
  59150. useVertexAlpha?: boolean;
  59151. }, scene?: Nullable<Scene>): LinesMesh;
  59152. /**
  59153. * Creates a dashed line mesh
  59154. * * 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
  59155. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59156. * * The parameter `points` is an array successive Vector3
  59157. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59158. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59159. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59160. * * 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
  59161. * * When updating an instance, remember that only point positions can change, not the number of points
  59162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59163. * @param name defines the name of the mesh
  59164. * @param options defines the options used to create the mesh
  59165. * @param scene defines the hosting scene
  59166. * @returns the dashed line mesh
  59167. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59168. */
  59169. static CreateDashedLines(name: string, options: {
  59170. points: Vector3[];
  59171. dashSize?: number;
  59172. gapSize?: number;
  59173. dashNb?: number;
  59174. updatable?: boolean;
  59175. instance?: LinesMesh;
  59176. }, scene?: Nullable<Scene>): LinesMesh;
  59177. /**
  59178. * 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.
  59179. * * 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.
  59180. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59181. * * 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.
  59182. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59183. * * 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
  59184. * * 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
  59185. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59188. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59190. * @param name defines the name of the mesh
  59191. * @param options defines the options used to create the mesh
  59192. * @param scene defines the hosting scene
  59193. * @returns the extruded shape mesh
  59194. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59195. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59196. */
  59197. static ExtrudeShape(name: string, options: {
  59198. shape: Vector3[];
  59199. path: Vector3[];
  59200. scale?: number;
  59201. rotation?: number;
  59202. cap?: number;
  59203. updatable?: boolean;
  59204. sideOrientation?: number;
  59205. frontUVs?: Vector4;
  59206. backUVs?: Vector4;
  59207. instance?: Mesh;
  59208. invertUV?: boolean;
  59209. }, scene?: Nullable<Scene>): Mesh;
  59210. /**
  59211. * Creates an custom extruded shape mesh.
  59212. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59213. * * 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.
  59214. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59215. * * 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
  59216. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59217. * * 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
  59218. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59219. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59220. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59221. * * 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
  59222. * * 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
  59223. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59225. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59226. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59228. * @param name defines the name of the mesh
  59229. * @param options defines the options used to create the mesh
  59230. * @param scene defines the hosting scene
  59231. * @returns the custom extruded shape mesh
  59232. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59233. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59234. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59235. */
  59236. static ExtrudeShapeCustom(name: string, options: {
  59237. shape: Vector3[];
  59238. path: Vector3[];
  59239. scaleFunction?: any;
  59240. rotationFunction?: any;
  59241. ribbonCloseArray?: boolean;
  59242. ribbonClosePath?: boolean;
  59243. cap?: number;
  59244. updatable?: boolean;
  59245. sideOrientation?: number;
  59246. frontUVs?: Vector4;
  59247. backUVs?: Vector4;
  59248. instance?: Mesh;
  59249. invertUV?: boolean;
  59250. }, scene?: Nullable<Scene>): Mesh;
  59251. /**
  59252. * Creates lathe mesh.
  59253. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59254. * * 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
  59255. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59256. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59257. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59258. * * 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
  59259. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59260. * * 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
  59261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59262. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59263. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59265. * @param name defines the name of the mesh
  59266. * @param options defines the options used to create the mesh
  59267. * @param scene defines the hosting scene
  59268. * @returns the lathe mesh
  59269. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59270. */
  59271. static CreateLathe(name: string, options: {
  59272. shape: Vector3[];
  59273. radius?: number;
  59274. tessellation?: number;
  59275. clip?: number;
  59276. arc?: number;
  59277. closed?: boolean;
  59278. updatable?: boolean;
  59279. sideOrientation?: number;
  59280. frontUVs?: Vector4;
  59281. backUVs?: Vector4;
  59282. cap?: number;
  59283. invertUV?: boolean;
  59284. }, scene?: Nullable<Scene>): Mesh;
  59285. /**
  59286. * Creates a tiled plane mesh
  59287. * * You can set a limited pattern arrangement with the tiles
  59288. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59289. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59291. * @param name defines the name of the mesh
  59292. * @param options defines the options used to create the mesh
  59293. * @param scene defines the hosting scene
  59294. * @returns the plane mesh
  59295. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59296. */
  59297. static CreateTiledPlane(name: string, options: {
  59298. pattern?: number;
  59299. tileSize?: number;
  59300. tileWidth?: number;
  59301. tileHeight?: number;
  59302. size?: number;
  59303. width?: number;
  59304. height?: number;
  59305. alignHorizontal?: number;
  59306. alignVertical?: number;
  59307. sideOrientation?: number;
  59308. frontUVs?: Vector4;
  59309. backUVs?: Vector4;
  59310. updatable?: boolean;
  59311. }, scene?: Nullable<Scene>): Mesh;
  59312. /**
  59313. * Creates a plane mesh
  59314. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59315. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59316. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59318. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59320. * @param name defines the name of the mesh
  59321. * @param options defines the options used to create the mesh
  59322. * @param scene defines the hosting scene
  59323. * @returns the plane mesh
  59324. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59325. */
  59326. static CreatePlane(name: string, options: {
  59327. size?: number;
  59328. width?: number;
  59329. height?: number;
  59330. sideOrientation?: number;
  59331. frontUVs?: Vector4;
  59332. backUVs?: Vector4;
  59333. updatable?: boolean;
  59334. sourcePlane?: Plane;
  59335. }, scene?: Nullable<Scene>): Mesh;
  59336. /**
  59337. * Creates a ground mesh
  59338. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59339. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59341. * @param name defines the name of the mesh
  59342. * @param options defines the options used to create the mesh
  59343. * @param scene defines the hosting scene
  59344. * @returns the ground mesh
  59345. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59346. */
  59347. static CreateGround(name: string, options: {
  59348. width?: number;
  59349. height?: number;
  59350. subdivisions?: number;
  59351. subdivisionsX?: number;
  59352. subdivisionsY?: number;
  59353. updatable?: boolean;
  59354. }, scene?: Nullable<Scene>): Mesh;
  59355. /**
  59356. * Creates a tiled ground mesh
  59357. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59358. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59359. * * 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
  59360. * * 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
  59361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59362. * @param name defines the name of the mesh
  59363. * @param options defines the options used to create the mesh
  59364. * @param scene defines the hosting scene
  59365. * @returns the tiled ground mesh
  59366. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59367. */
  59368. static CreateTiledGround(name: string, options: {
  59369. xmin: number;
  59370. zmin: number;
  59371. xmax: number;
  59372. zmax: number;
  59373. subdivisions?: {
  59374. w: number;
  59375. h: number;
  59376. };
  59377. precision?: {
  59378. w: number;
  59379. h: number;
  59380. };
  59381. updatable?: boolean;
  59382. }, scene?: Nullable<Scene>): Mesh;
  59383. /**
  59384. * Creates a ground mesh from a height map
  59385. * * The parameter `url` sets the URL of the height map image resource.
  59386. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59387. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59388. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59389. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59390. * * 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.
  59391. * * 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).
  59392. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59394. * @param name defines the name of the mesh
  59395. * @param url defines the url to the height map
  59396. * @param options defines the options used to create the mesh
  59397. * @param scene defines the hosting scene
  59398. * @returns the ground mesh
  59399. * @see https://doc.babylonjs.com/babylon101/height_map
  59400. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59401. */
  59402. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59403. width?: number;
  59404. height?: number;
  59405. subdivisions?: number;
  59406. minHeight?: number;
  59407. maxHeight?: number;
  59408. colorFilter?: Color3;
  59409. alphaFilter?: number;
  59410. updatable?: boolean;
  59411. onReady?: (mesh: GroundMesh) => void;
  59412. }, scene?: Nullable<Scene>): GroundMesh;
  59413. /**
  59414. * Creates a polygon mesh
  59415. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59416. * * 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
  59417. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59419. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59420. * * Remember you can only change the shape positions, not their number when updating a polygon
  59421. * @param name defines the name of the mesh
  59422. * @param options defines the options used to create the mesh
  59423. * @param scene defines the hosting scene
  59424. * @param earcutInjection can be used to inject your own earcut reference
  59425. * @returns the polygon mesh
  59426. */
  59427. static CreatePolygon(name: string, options: {
  59428. shape: Vector3[];
  59429. holes?: Vector3[][];
  59430. depth?: number;
  59431. faceUV?: Vector4[];
  59432. faceColors?: Color4[];
  59433. updatable?: boolean;
  59434. sideOrientation?: number;
  59435. frontUVs?: Vector4;
  59436. backUVs?: Vector4;
  59437. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59438. /**
  59439. * Creates an extruded polygon mesh, with depth in the Y direction.
  59440. * * 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)
  59441. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59442. * @param name defines the name of the mesh
  59443. * @param options defines the options used to create the mesh
  59444. * @param scene defines the hosting scene
  59445. * @param earcutInjection can be used to inject your own earcut reference
  59446. * @returns the polygon mesh
  59447. */
  59448. static ExtrudePolygon(name: string, options: {
  59449. shape: Vector3[];
  59450. holes?: Vector3[][];
  59451. depth?: number;
  59452. faceUV?: Vector4[];
  59453. faceColors?: Color4[];
  59454. updatable?: boolean;
  59455. sideOrientation?: number;
  59456. frontUVs?: Vector4;
  59457. backUVs?: Vector4;
  59458. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59459. /**
  59460. * Creates a tube mesh.
  59461. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59462. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59463. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59464. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59465. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59466. * * 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)
  59467. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59468. * * 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
  59469. * * 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
  59470. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59471. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59472. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59474. * @param name defines the name of the mesh
  59475. * @param options defines the options used to create the mesh
  59476. * @param scene defines the hosting scene
  59477. * @returns the tube mesh
  59478. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59479. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59480. */
  59481. static CreateTube(name: string, options: {
  59482. path: Vector3[];
  59483. radius?: number;
  59484. tessellation?: number;
  59485. radiusFunction?: {
  59486. (i: number, distance: number): number;
  59487. };
  59488. cap?: number;
  59489. arc?: number;
  59490. updatable?: boolean;
  59491. sideOrientation?: number;
  59492. frontUVs?: Vector4;
  59493. backUVs?: Vector4;
  59494. instance?: Mesh;
  59495. invertUV?: boolean;
  59496. }, scene?: Nullable<Scene>): Mesh;
  59497. /**
  59498. * Creates a polyhedron mesh
  59499. * * 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
  59500. * * The parameter `size` (positive float, default 1) sets the polygon size
  59501. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59502. * * 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`
  59503. * * 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
  59504. * * 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)`)
  59505. * * 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
  59506. * * 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
  59507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59508. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59510. * @param name defines the name of the mesh
  59511. * @param options defines the options used to create the mesh
  59512. * @param scene defines the hosting scene
  59513. * @returns the polyhedron mesh
  59514. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59515. */
  59516. static CreatePolyhedron(name: string, options: {
  59517. type?: number;
  59518. size?: number;
  59519. sizeX?: number;
  59520. sizeY?: number;
  59521. sizeZ?: number;
  59522. custom?: any;
  59523. faceUV?: Vector4[];
  59524. faceColors?: Color4[];
  59525. flat?: boolean;
  59526. updatable?: boolean;
  59527. sideOrientation?: number;
  59528. frontUVs?: Vector4;
  59529. backUVs?: Vector4;
  59530. }, scene?: Nullable<Scene>): Mesh;
  59531. /**
  59532. * Creates a decal mesh.
  59533. * 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
  59534. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59535. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59536. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59537. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59538. * @param name defines the name of the mesh
  59539. * @param sourceMesh defines the mesh where the decal must be applied
  59540. * @param options defines the options used to create the mesh
  59541. * @param scene defines the hosting scene
  59542. * @returns the decal mesh
  59543. * @see https://doc.babylonjs.com/how_to/decals
  59544. */
  59545. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59546. position?: Vector3;
  59547. normal?: Vector3;
  59548. size?: Vector3;
  59549. angle?: number;
  59550. }): Mesh;
  59551. }
  59552. }
  59553. declare module "babylonjs/Meshes/meshSimplification" {
  59554. import { Mesh } from "babylonjs/Meshes/mesh";
  59555. /**
  59556. * A simplifier interface for future simplification implementations
  59557. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59558. */
  59559. export interface ISimplifier {
  59560. /**
  59561. * Simplification of a given mesh according to the given settings.
  59562. * Since this requires computation, it is assumed that the function runs async.
  59563. * @param settings The settings of the simplification, including quality and distance
  59564. * @param successCallback A callback that will be called after the mesh was simplified.
  59565. * @param errorCallback in case of an error, this callback will be called. optional.
  59566. */
  59567. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59568. }
  59569. /**
  59570. * Expected simplification settings.
  59571. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59572. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59573. */
  59574. export interface ISimplificationSettings {
  59575. /**
  59576. * Gets or sets the expected quality
  59577. */
  59578. quality: number;
  59579. /**
  59580. * Gets or sets the distance when this optimized version should be used
  59581. */
  59582. distance: number;
  59583. /**
  59584. * Gets an already optimized mesh
  59585. */
  59586. optimizeMesh?: boolean;
  59587. }
  59588. /**
  59589. * Class used to specify simplification options
  59590. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59591. */
  59592. export class SimplificationSettings implements ISimplificationSettings {
  59593. /** expected quality */
  59594. quality: number;
  59595. /** distance when this optimized version should be used */
  59596. distance: number;
  59597. /** already optimized mesh */
  59598. optimizeMesh?: boolean | undefined;
  59599. /**
  59600. * Creates a SimplificationSettings
  59601. * @param quality expected quality
  59602. * @param distance distance when this optimized version should be used
  59603. * @param optimizeMesh already optimized mesh
  59604. */
  59605. constructor(
  59606. /** expected quality */
  59607. quality: number,
  59608. /** distance when this optimized version should be used */
  59609. distance: number,
  59610. /** already optimized mesh */
  59611. optimizeMesh?: boolean | undefined);
  59612. }
  59613. /**
  59614. * Interface used to define a simplification task
  59615. */
  59616. export interface ISimplificationTask {
  59617. /**
  59618. * Array of settings
  59619. */
  59620. settings: Array<ISimplificationSettings>;
  59621. /**
  59622. * Simplification type
  59623. */
  59624. simplificationType: SimplificationType;
  59625. /**
  59626. * Mesh to simplify
  59627. */
  59628. mesh: Mesh;
  59629. /**
  59630. * Callback called on success
  59631. */
  59632. successCallback?: () => void;
  59633. /**
  59634. * Defines if parallel processing can be used
  59635. */
  59636. parallelProcessing: boolean;
  59637. }
  59638. /**
  59639. * Queue used to order the simplification tasks
  59640. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59641. */
  59642. export class SimplificationQueue {
  59643. private _simplificationArray;
  59644. /**
  59645. * Gets a boolean indicating that the process is still running
  59646. */
  59647. running: boolean;
  59648. /**
  59649. * Creates a new queue
  59650. */
  59651. constructor();
  59652. /**
  59653. * Adds a new simplification task
  59654. * @param task defines a task to add
  59655. */
  59656. addTask(task: ISimplificationTask): void;
  59657. /**
  59658. * Execute next task
  59659. */
  59660. executeNext(): void;
  59661. /**
  59662. * Execute a simplification task
  59663. * @param task defines the task to run
  59664. */
  59665. runSimplification(task: ISimplificationTask): void;
  59666. private getSimplifier;
  59667. }
  59668. /**
  59669. * The implemented types of simplification
  59670. * At the moment only Quadratic Error Decimation is implemented
  59671. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59672. */
  59673. export enum SimplificationType {
  59674. /** Quadratic error decimation */
  59675. QUADRATIC = 0
  59676. }
  59677. }
  59678. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  59679. import { Scene } from "babylonjs/scene";
  59680. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  59681. import { ISceneComponent } from "babylonjs/sceneComponent";
  59682. module "babylonjs/scene" {
  59683. interface Scene {
  59684. /** @hidden (Backing field) */
  59685. _simplificationQueue: SimplificationQueue;
  59686. /**
  59687. * Gets or sets the simplification queue attached to the scene
  59688. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59689. */
  59690. simplificationQueue: SimplificationQueue;
  59691. }
  59692. }
  59693. module "babylonjs/Meshes/mesh" {
  59694. interface Mesh {
  59695. /**
  59696. * Simplify the mesh according to the given array of settings.
  59697. * Function will return immediately and will simplify async
  59698. * @param settings a collection of simplification settings
  59699. * @param parallelProcessing should all levels calculate parallel or one after the other
  59700. * @param simplificationType the type of simplification to run
  59701. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  59702. * @returns the current mesh
  59703. */
  59704. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  59705. }
  59706. }
  59707. /**
  59708. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  59709. * created in a scene
  59710. */
  59711. export class SimplicationQueueSceneComponent implements ISceneComponent {
  59712. /**
  59713. * The component name helpfull to identify the component in the list of scene components.
  59714. */
  59715. readonly name: string;
  59716. /**
  59717. * The scene the component belongs to.
  59718. */
  59719. scene: Scene;
  59720. /**
  59721. * Creates a new instance of the component for the given scene
  59722. * @param scene Defines the scene to register the component in
  59723. */
  59724. constructor(scene: Scene);
  59725. /**
  59726. * Registers the component in a given scene
  59727. */
  59728. register(): void;
  59729. /**
  59730. * Rebuilds the elements related to this component in case of
  59731. * context lost for instance.
  59732. */
  59733. rebuild(): void;
  59734. /**
  59735. * Disposes the component and the associated ressources
  59736. */
  59737. dispose(): void;
  59738. private _beforeCameraUpdate;
  59739. }
  59740. }
  59741. declare module "babylonjs/Meshes/Builders/index" {
  59742. export * from "babylonjs/Meshes/Builders/boxBuilder";
  59743. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  59744. export * from "babylonjs/Meshes/Builders/discBuilder";
  59745. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  59746. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  59747. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  59748. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  59749. export * from "babylonjs/Meshes/Builders/torusBuilder";
  59750. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  59751. export * from "babylonjs/Meshes/Builders/linesBuilder";
  59752. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  59753. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  59754. export * from "babylonjs/Meshes/Builders/latheBuilder";
  59755. export * from "babylonjs/Meshes/Builders/planeBuilder";
  59756. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  59757. export * from "babylonjs/Meshes/Builders/groundBuilder";
  59758. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  59759. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  59760. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  59761. export * from "babylonjs/Meshes/Builders/decalBuilder";
  59762. }
  59763. declare module "babylonjs/Meshes/index" {
  59764. export * from "babylonjs/Meshes/abstractMesh";
  59765. export * from "babylonjs/Meshes/buffer";
  59766. export * from "babylonjs/Meshes/Compression/index";
  59767. export * from "babylonjs/Meshes/csg";
  59768. export * from "babylonjs/Meshes/geometry";
  59769. export * from "babylonjs/Meshes/groundMesh";
  59770. export * from "babylonjs/Meshes/trailMesh";
  59771. export * from "babylonjs/Meshes/instancedMesh";
  59772. export * from "babylonjs/Meshes/linesMesh";
  59773. export * from "babylonjs/Meshes/mesh";
  59774. export * from "babylonjs/Meshes/mesh.vertexData";
  59775. export * from "babylonjs/Meshes/meshBuilder";
  59776. export * from "babylonjs/Meshes/meshSimplification";
  59777. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  59778. export * from "babylonjs/Meshes/polygonMesh";
  59779. export * from "babylonjs/Meshes/subMesh";
  59780. export * from "babylonjs/Meshes/meshLODLevel";
  59781. export * from "babylonjs/Meshes/transformNode";
  59782. export * from "babylonjs/Meshes/Builders/index";
  59783. export * from "babylonjs/Meshes/dataBuffer";
  59784. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  59785. }
  59786. declare module "babylonjs/Morph/index" {
  59787. export * from "babylonjs/Morph/morphTarget";
  59788. export * from "babylonjs/Morph/morphTargetManager";
  59789. }
  59790. declare module "babylonjs/Navigation/INavigationEngine" {
  59791. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59792. import { Vector3 } from "babylonjs/Maths/math";
  59793. import { Mesh } from "babylonjs/Meshes/mesh";
  59794. import { Scene } from "babylonjs/scene";
  59795. /**
  59796. * Navigation plugin interface to add navigation constrained by a navigation mesh
  59797. */
  59798. export interface INavigationEnginePlugin {
  59799. /**
  59800. * plugin name
  59801. */
  59802. name: string;
  59803. /**
  59804. * Creates a navigation mesh
  59805. * @param meshes array of all the geometry used to compute the navigatio mesh
  59806. * @param parameters bunch of parameters used to filter geometry
  59807. */
  59808. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59809. /**
  59810. * Create a navigation mesh debug mesh
  59811. * @param scene is where the mesh will be added
  59812. * @returns debug display mesh
  59813. */
  59814. createDebugNavMesh(scene: Scene): Mesh;
  59815. /**
  59816. * Get a navigation mesh constrained position, closest to the parameter position
  59817. * @param position world position
  59818. * @returns the closest point to position constrained by the navigation mesh
  59819. */
  59820. getClosestPoint(position: Vector3): Vector3;
  59821. /**
  59822. * Get a navigation mesh constrained position, within a particular radius
  59823. * @param position world position
  59824. * @param maxRadius the maximum distance to the constrained world position
  59825. * @returns the closest point to position constrained by the navigation mesh
  59826. */
  59827. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59828. /**
  59829. * Compute the final position from a segment made of destination-position
  59830. * @param position world position
  59831. * @param destination world position
  59832. * @returns the resulting point along the navmesh
  59833. */
  59834. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59835. /**
  59836. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59837. * @param start world position
  59838. * @param end world position
  59839. * @returns array containing world position composing the path
  59840. */
  59841. computePath(start: Vector3, end: Vector3): Vector3[];
  59842. /**
  59843. * If this plugin is supported
  59844. * @returns true if plugin is supported
  59845. */
  59846. isSupported(): boolean;
  59847. /**
  59848. * Create a new Crowd so you can add agents
  59849. * @param maxAgents the maximum agent count in the crowd
  59850. * @param maxAgentRadius the maximum radius an agent can have
  59851. * @param scene to attach the crowd to
  59852. * @returns the crowd you can add agents to
  59853. */
  59854. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59855. /**
  59856. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59857. * The queries will try to find a solution within those bounds
  59858. * default is (1,1,1)
  59859. * @param extent x,y,z value that define the extent around the queries point of reference
  59860. */
  59861. setDefaultQueryExtent(extent: Vector3): void;
  59862. /**
  59863. * Get the Bounding box extent specified by setDefaultQueryExtent
  59864. * @returns the box extent values
  59865. */
  59866. getDefaultQueryExtent(): Vector3;
  59867. /**
  59868. * Release all resources
  59869. */
  59870. dispose(): void;
  59871. }
  59872. /**
  59873. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  59874. */
  59875. export interface ICrowd {
  59876. /**
  59877. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59878. * You can attach anything to that node. The node position is updated in the scene update tick.
  59879. * @param pos world position that will be constrained by the navigation mesh
  59880. * @param parameters agent parameters
  59881. * @param transform hooked to the agent that will be update by the scene
  59882. * @returns agent index
  59883. */
  59884. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59885. /**
  59886. * Returns the agent position in world space
  59887. * @param index agent index returned by addAgent
  59888. * @returns world space position
  59889. */
  59890. getAgentPosition(index: number): Vector3;
  59891. /**
  59892. * Gets the agent velocity in world space
  59893. * @param index agent index returned by addAgent
  59894. * @returns world space velocity
  59895. */
  59896. getAgentVelocity(index: number): Vector3;
  59897. /**
  59898. * remove a particular agent previously created
  59899. * @param index agent index returned by addAgent
  59900. */
  59901. removeAgent(index: number): void;
  59902. /**
  59903. * get the list of all agents attached to this crowd
  59904. * @returns list of agent indices
  59905. */
  59906. getAgents(): number[];
  59907. /**
  59908. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59909. * @param deltaTime in seconds
  59910. */
  59911. update(deltaTime: number): void;
  59912. /**
  59913. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59914. * @param index agent index returned by addAgent
  59915. * @param destination targeted world position
  59916. */
  59917. agentGoto(index: number, destination: Vector3): void;
  59918. /**
  59919. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59920. * The queries will try to find a solution within those bounds
  59921. * default is (1,1,1)
  59922. * @param extent x,y,z value that define the extent around the queries point of reference
  59923. */
  59924. setDefaultQueryExtent(extent: Vector3): void;
  59925. /**
  59926. * Get the Bounding box extent specified by setDefaultQueryExtent
  59927. * @returns the box extent values
  59928. */
  59929. getDefaultQueryExtent(): Vector3;
  59930. /**
  59931. * Release all resources
  59932. */
  59933. dispose(): void;
  59934. }
  59935. /**
  59936. * Configures an agent
  59937. */
  59938. export interface IAgentParameters {
  59939. /**
  59940. * Agent radius. [Limit: >= 0]
  59941. */
  59942. radius: number;
  59943. /**
  59944. * Agent height. [Limit: > 0]
  59945. */
  59946. height: number;
  59947. /**
  59948. * Maximum allowed acceleration. [Limit: >= 0]
  59949. */
  59950. maxAcceleration: number;
  59951. /**
  59952. * Maximum allowed speed. [Limit: >= 0]
  59953. */
  59954. maxSpeed: number;
  59955. /**
  59956. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  59957. */
  59958. collisionQueryRange: number;
  59959. /**
  59960. * The path visibility optimization range. [Limit: > 0]
  59961. */
  59962. pathOptimizationRange: number;
  59963. /**
  59964. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  59965. */
  59966. separationWeight: number;
  59967. }
  59968. /**
  59969. * Configures the navigation mesh creation
  59970. */
  59971. export interface INavMeshParameters {
  59972. /**
  59973. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  59974. */
  59975. cs: number;
  59976. /**
  59977. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  59978. */
  59979. ch: number;
  59980. /**
  59981. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  59982. */
  59983. walkableSlopeAngle: number;
  59984. /**
  59985. * Minimum floor to 'ceiling' height that will still allow the floor area to
  59986. * be considered walkable. [Limit: >= 3] [Units: vx]
  59987. */
  59988. walkableHeight: number;
  59989. /**
  59990. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  59991. */
  59992. walkableClimb: number;
  59993. /**
  59994. * The distance to erode/shrink the walkable area of the heightfield away from
  59995. * obstructions. [Limit: >=0] [Units: vx]
  59996. */
  59997. walkableRadius: number;
  59998. /**
  59999. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60000. */
  60001. maxEdgeLen: number;
  60002. /**
  60003. * The maximum distance a simplfied contour's border edges should deviate
  60004. * the original raw contour. [Limit: >=0] [Units: vx]
  60005. */
  60006. maxSimplificationError: number;
  60007. /**
  60008. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60009. */
  60010. minRegionArea: number;
  60011. /**
  60012. * Any regions with a span count smaller than this value will, if possible,
  60013. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60014. */
  60015. mergeRegionArea: number;
  60016. /**
  60017. * The maximum number of vertices allowed for polygons generated during the
  60018. * contour to polygon conversion process. [Limit: >= 3]
  60019. */
  60020. maxVertsPerPoly: number;
  60021. /**
  60022. * Sets the sampling distance to use when generating the detail mesh.
  60023. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60024. */
  60025. detailSampleDist: number;
  60026. /**
  60027. * The maximum distance the detail mesh surface should deviate from heightfield
  60028. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60029. */
  60030. detailSampleMaxError: number;
  60031. }
  60032. }
  60033. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60034. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60035. import { Mesh } from "babylonjs/Meshes/mesh";
  60036. import { Scene } from "babylonjs/scene";
  60037. import { Vector3 } from "babylonjs/Maths/math";
  60038. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60039. /**
  60040. * RecastJS navigation plugin
  60041. */
  60042. export class RecastJSPlugin implements INavigationEnginePlugin {
  60043. /**
  60044. * Reference to the Recast library
  60045. */
  60046. bjsRECAST: any;
  60047. /**
  60048. * plugin name
  60049. */
  60050. name: string;
  60051. /**
  60052. * the first navmesh created. We might extend this to support multiple navmeshes
  60053. */
  60054. navMesh: any;
  60055. /**
  60056. * Initializes the recastJS plugin
  60057. * @param recastInjection can be used to inject your own recast reference
  60058. */
  60059. constructor(recastInjection?: any);
  60060. /**
  60061. * Creates a navigation mesh
  60062. * @param meshes array of all the geometry used to compute the navigatio mesh
  60063. * @param parameters bunch of parameters used to filter geometry
  60064. */
  60065. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60066. /**
  60067. * Create a navigation mesh debug mesh
  60068. * @param scene is where the mesh will be added
  60069. * @returns debug display mesh
  60070. */
  60071. createDebugNavMesh(scene: Scene): Mesh;
  60072. /**
  60073. * Get a navigation mesh constrained position, closest to the parameter position
  60074. * @param position world position
  60075. * @returns the closest point to position constrained by the navigation mesh
  60076. */
  60077. getClosestPoint(position: Vector3): Vector3;
  60078. /**
  60079. * Get a navigation mesh constrained position, within a particular radius
  60080. * @param position world position
  60081. * @param maxRadius the maximum distance to the constrained world position
  60082. * @returns the closest point to position constrained by the navigation mesh
  60083. */
  60084. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60085. /**
  60086. * Compute the final position from a segment made of destination-position
  60087. * @param position world position
  60088. * @param destination world position
  60089. * @returns the resulting point along the navmesh
  60090. */
  60091. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60092. /**
  60093. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60094. * @param start world position
  60095. * @param end world position
  60096. * @returns array containing world position composing the path
  60097. */
  60098. computePath(start: Vector3, end: Vector3): Vector3[];
  60099. /**
  60100. * Create a new Crowd so you can add agents
  60101. * @param maxAgents the maximum agent count in the crowd
  60102. * @param maxAgentRadius the maximum radius an agent can have
  60103. * @param scene to attach the crowd to
  60104. * @returns the crowd you can add agents to
  60105. */
  60106. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60107. /**
  60108. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60109. * The queries will try to find a solution within those bounds
  60110. * default is (1,1,1)
  60111. * @param extent x,y,z value that define the extent around the queries point of reference
  60112. */
  60113. setDefaultQueryExtent(extent: Vector3): void;
  60114. /**
  60115. * Get the Bounding box extent specified by setDefaultQueryExtent
  60116. * @returns the box extent values
  60117. */
  60118. getDefaultQueryExtent(): Vector3;
  60119. /**
  60120. * Disposes
  60121. */
  60122. dispose(): void;
  60123. /**
  60124. * If this plugin is supported
  60125. * @returns true if plugin is supported
  60126. */
  60127. isSupported(): boolean;
  60128. }
  60129. /**
  60130. * Recast detour crowd implementation
  60131. */
  60132. export class RecastJSCrowd implements ICrowd {
  60133. /**
  60134. * Recast/detour plugin
  60135. */
  60136. bjsRECASTPlugin: RecastJSPlugin;
  60137. /**
  60138. * Link to the detour crowd
  60139. */
  60140. recastCrowd: any;
  60141. /**
  60142. * One transform per agent
  60143. */
  60144. transforms: TransformNode[];
  60145. /**
  60146. * All agents created
  60147. */
  60148. agents: number[];
  60149. /**
  60150. * Link to the scene is kept to unregister the crowd from the scene
  60151. */
  60152. private _scene;
  60153. /**
  60154. * Observer for crowd updates
  60155. */
  60156. private _onBeforeAnimationsObserver;
  60157. /**
  60158. * Constructor
  60159. * @param plugin recastJS plugin
  60160. * @param maxAgents the maximum agent count in the crowd
  60161. * @param maxAgentRadius the maximum radius an agent can have
  60162. * @param scene to attach the crowd to
  60163. * @returns the crowd you can add agents to
  60164. */
  60165. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60166. /**
  60167. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60168. * You can attach anything to that node. The node position is updated in the scene update tick.
  60169. * @param pos world position that will be constrained by the navigation mesh
  60170. * @param parameters agent parameters
  60171. * @param transform hooked to the agent that will be update by the scene
  60172. * @returns agent index
  60173. */
  60174. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60175. /**
  60176. * Returns the agent position in world space
  60177. * @param index agent index returned by addAgent
  60178. * @returns world space position
  60179. */
  60180. getAgentPosition(index: number): Vector3;
  60181. /**
  60182. * Returns the agent velocity in world space
  60183. * @param index agent index returned by addAgent
  60184. * @returns world space velocity
  60185. */
  60186. getAgentVelocity(index: number): Vector3;
  60187. /**
  60188. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60189. * @param index agent index returned by addAgent
  60190. * @param destination targeted world position
  60191. */
  60192. agentGoto(index: number, destination: Vector3): void;
  60193. /**
  60194. * remove a particular agent previously created
  60195. * @param index agent index returned by addAgent
  60196. */
  60197. removeAgent(index: number): void;
  60198. /**
  60199. * get the list of all agents attached to this crowd
  60200. * @returns list of agent indices
  60201. */
  60202. getAgents(): number[];
  60203. /**
  60204. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60205. * @param deltaTime in seconds
  60206. */
  60207. update(deltaTime: number): void;
  60208. /**
  60209. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60210. * The queries will try to find a solution within those bounds
  60211. * default is (1,1,1)
  60212. * @param extent x,y,z value that define the extent around the queries point of reference
  60213. */
  60214. setDefaultQueryExtent(extent: Vector3): void;
  60215. /**
  60216. * Get the Bounding box extent specified by setDefaultQueryExtent
  60217. * @returns the box extent values
  60218. */
  60219. getDefaultQueryExtent(): Vector3;
  60220. /**
  60221. * Release all resources
  60222. */
  60223. dispose(): void;
  60224. }
  60225. }
  60226. declare module "babylonjs/Navigation/Plugins/index" {
  60227. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  60228. }
  60229. declare module "babylonjs/Navigation/index" {
  60230. export * from "babylonjs/Navigation/INavigationEngine";
  60231. export * from "babylonjs/Navigation/Plugins/index";
  60232. }
  60233. declare module "babylonjs/Offline/database" {
  60234. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  60235. /**
  60236. * Class used to enable access to IndexedDB
  60237. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60238. */
  60239. export class Database implements IOfflineProvider {
  60240. private _callbackManifestChecked;
  60241. private _currentSceneUrl;
  60242. private _db;
  60243. private _enableSceneOffline;
  60244. private _enableTexturesOffline;
  60245. private _manifestVersionFound;
  60246. private _mustUpdateRessources;
  60247. private _hasReachedQuota;
  60248. private _isSupported;
  60249. private _idbFactory;
  60250. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60251. private static IsUASupportingBlobStorage;
  60252. /**
  60253. * Gets a boolean indicating if Database storate is enabled (off by default)
  60254. */
  60255. static IDBStorageEnabled: boolean;
  60256. /**
  60257. * Gets a boolean indicating if scene must be saved in the database
  60258. */
  60259. readonly enableSceneOffline: boolean;
  60260. /**
  60261. * Gets a boolean indicating if textures must be saved in the database
  60262. */
  60263. readonly enableTexturesOffline: boolean;
  60264. /**
  60265. * Creates a new Database
  60266. * @param urlToScene defines the url to load the scene
  60267. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60268. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60269. */
  60270. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60271. private static _ParseURL;
  60272. private static _ReturnFullUrlLocation;
  60273. private _checkManifestFile;
  60274. /**
  60275. * Open the database and make it available
  60276. * @param successCallback defines the callback to call on success
  60277. * @param errorCallback defines the callback to call on error
  60278. */
  60279. open(successCallback: () => void, errorCallback: () => void): void;
  60280. /**
  60281. * Loads an image from the database
  60282. * @param url defines the url to load from
  60283. * @param image defines the target DOM image
  60284. */
  60285. loadImage(url: string, image: HTMLImageElement): void;
  60286. private _loadImageFromDBAsync;
  60287. private _saveImageIntoDBAsync;
  60288. private _checkVersionFromDB;
  60289. private _loadVersionFromDBAsync;
  60290. private _saveVersionIntoDBAsync;
  60291. /**
  60292. * Loads a file from database
  60293. * @param url defines the URL to load from
  60294. * @param sceneLoaded defines a callback to call on success
  60295. * @param progressCallBack defines a callback to call when progress changed
  60296. * @param errorCallback defines a callback to call on error
  60297. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60298. */
  60299. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60300. private _loadFileAsync;
  60301. private _saveFileAsync;
  60302. /**
  60303. * Validates if xhr data is correct
  60304. * @param xhr defines the request to validate
  60305. * @param dataType defines the expected data type
  60306. * @returns true if data is correct
  60307. */
  60308. private static _ValidateXHRData;
  60309. }
  60310. }
  60311. declare module "babylonjs/Offline/index" {
  60312. export * from "babylonjs/Offline/database";
  60313. export * from "babylonjs/Offline/IOfflineProvider";
  60314. }
  60315. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  60316. /** @hidden */
  60317. export var gpuUpdateParticlesPixelShader: {
  60318. name: string;
  60319. shader: string;
  60320. };
  60321. }
  60322. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  60323. /** @hidden */
  60324. export var gpuUpdateParticlesVertexShader: {
  60325. name: string;
  60326. shader: string;
  60327. };
  60328. }
  60329. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  60330. /** @hidden */
  60331. export var clipPlaneFragmentDeclaration2: {
  60332. name: string;
  60333. shader: string;
  60334. };
  60335. }
  60336. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  60337. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  60338. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60339. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60340. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60341. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60342. /** @hidden */
  60343. export var gpuRenderParticlesPixelShader: {
  60344. name: string;
  60345. shader: string;
  60346. };
  60347. }
  60348. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  60349. /** @hidden */
  60350. export var clipPlaneVertexDeclaration2: {
  60351. name: string;
  60352. shader: string;
  60353. };
  60354. }
  60355. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  60356. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  60357. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60358. /** @hidden */
  60359. export var gpuRenderParticlesVertexShader: {
  60360. name: string;
  60361. shader: string;
  60362. };
  60363. }
  60364. declare module "babylonjs/Particles/gpuParticleSystem" {
  60365. import { Nullable } from "babylonjs/types";
  60366. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  60367. import { Observable } from "babylonjs/Misc/observable";
  60368. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60369. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60370. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  60371. import { Scene, IDisposable } from "babylonjs/scene";
  60372. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  60373. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60374. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  60375. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  60376. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  60377. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  60378. /**
  60379. * This represents a GPU particle system in Babylon
  60380. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60381. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60382. */
  60383. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60384. /**
  60385. * The layer mask we are rendering the particles through.
  60386. */
  60387. layerMask: number;
  60388. private _capacity;
  60389. private _activeCount;
  60390. private _currentActiveCount;
  60391. private _accumulatedCount;
  60392. private _renderEffect;
  60393. private _updateEffect;
  60394. private _buffer0;
  60395. private _buffer1;
  60396. private _spriteBuffer;
  60397. private _updateVAO;
  60398. private _renderVAO;
  60399. private _targetIndex;
  60400. private _sourceBuffer;
  60401. private _targetBuffer;
  60402. private _engine;
  60403. private _currentRenderId;
  60404. private _started;
  60405. private _stopped;
  60406. private _timeDelta;
  60407. private _randomTexture;
  60408. private _randomTexture2;
  60409. private _attributesStrideSize;
  60410. private _updateEffectOptions;
  60411. private _randomTextureSize;
  60412. private _actualFrame;
  60413. private readonly _rawTextureWidth;
  60414. /**
  60415. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60416. */
  60417. static readonly IsSupported: boolean;
  60418. /**
  60419. * An event triggered when the system is disposed.
  60420. */
  60421. onDisposeObservable: Observable<GPUParticleSystem>;
  60422. /**
  60423. * Gets the maximum number of particles active at the same time.
  60424. * @returns The max number of active particles.
  60425. */
  60426. getCapacity(): number;
  60427. /**
  60428. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60429. * to override the particles.
  60430. */
  60431. forceDepthWrite: boolean;
  60432. /**
  60433. * Gets or set the number of active particles
  60434. */
  60435. activeParticleCount: number;
  60436. private _preWarmDone;
  60437. /**
  60438. * Is this system ready to be used/rendered
  60439. * @return true if the system is ready
  60440. */
  60441. isReady(): boolean;
  60442. /**
  60443. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60444. * @returns True if it has been started, otherwise false.
  60445. */
  60446. isStarted(): boolean;
  60447. /**
  60448. * Starts the particle system and begins to emit
  60449. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60450. */
  60451. start(delay?: number): void;
  60452. /**
  60453. * Stops the particle system.
  60454. */
  60455. stop(): void;
  60456. /**
  60457. * Remove all active particles
  60458. */
  60459. reset(): void;
  60460. /**
  60461. * Returns the string "GPUParticleSystem"
  60462. * @returns a string containing the class name
  60463. */
  60464. getClassName(): string;
  60465. private _colorGradientsTexture;
  60466. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60467. /**
  60468. * Adds a new color gradient
  60469. * @param gradient defines the gradient to use (between 0 and 1)
  60470. * @param color1 defines the color to affect to the specified gradient
  60471. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60472. * @returns the current particle system
  60473. */
  60474. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60475. /**
  60476. * Remove a specific color gradient
  60477. * @param gradient defines the gradient to remove
  60478. * @returns the current particle system
  60479. */
  60480. removeColorGradient(gradient: number): GPUParticleSystem;
  60481. private _angularSpeedGradientsTexture;
  60482. private _sizeGradientsTexture;
  60483. private _velocityGradientsTexture;
  60484. private _limitVelocityGradientsTexture;
  60485. private _dragGradientsTexture;
  60486. private _addFactorGradient;
  60487. /**
  60488. * Adds a new size gradient
  60489. * @param gradient defines the gradient to use (between 0 and 1)
  60490. * @param factor defines the size factor to affect to the specified gradient
  60491. * @returns the current particle system
  60492. */
  60493. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60494. /**
  60495. * Remove a specific size gradient
  60496. * @param gradient defines the gradient to remove
  60497. * @returns the current particle system
  60498. */
  60499. removeSizeGradient(gradient: number): GPUParticleSystem;
  60500. /**
  60501. * Adds a new angular speed gradient
  60502. * @param gradient defines the gradient to use (between 0 and 1)
  60503. * @param factor defines the angular speed to affect to the specified gradient
  60504. * @returns the current particle system
  60505. */
  60506. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60507. /**
  60508. * Remove a specific angular speed gradient
  60509. * @param gradient defines the gradient to remove
  60510. * @returns the current particle system
  60511. */
  60512. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60513. /**
  60514. * Adds a new velocity gradient
  60515. * @param gradient defines the gradient to use (between 0 and 1)
  60516. * @param factor defines the velocity to affect to the specified gradient
  60517. * @returns the current particle system
  60518. */
  60519. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60520. /**
  60521. * Remove a specific velocity gradient
  60522. * @param gradient defines the gradient to remove
  60523. * @returns the current particle system
  60524. */
  60525. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60526. /**
  60527. * Adds a new limit velocity gradient
  60528. * @param gradient defines the gradient to use (between 0 and 1)
  60529. * @param factor defines the limit velocity value to affect to the specified gradient
  60530. * @returns the current particle system
  60531. */
  60532. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60533. /**
  60534. * Remove a specific limit velocity gradient
  60535. * @param gradient defines the gradient to remove
  60536. * @returns the current particle system
  60537. */
  60538. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60539. /**
  60540. * Adds a new drag gradient
  60541. * @param gradient defines the gradient to use (between 0 and 1)
  60542. * @param factor defines the drag value to affect to the specified gradient
  60543. * @returns the current particle system
  60544. */
  60545. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60546. /**
  60547. * Remove a specific drag gradient
  60548. * @param gradient defines the gradient to remove
  60549. * @returns the current particle system
  60550. */
  60551. removeDragGradient(gradient: number): GPUParticleSystem;
  60552. /**
  60553. * Not supported by GPUParticleSystem
  60554. * @param gradient defines the gradient to use (between 0 and 1)
  60555. * @param factor defines the emit rate value to affect to the specified gradient
  60556. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60557. * @returns the current particle system
  60558. */
  60559. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60560. /**
  60561. * Not supported by GPUParticleSystem
  60562. * @param gradient defines the gradient to remove
  60563. * @returns the current particle system
  60564. */
  60565. removeEmitRateGradient(gradient: number): IParticleSystem;
  60566. /**
  60567. * Not supported by GPUParticleSystem
  60568. * @param gradient defines the gradient to use (between 0 and 1)
  60569. * @param factor defines the start size 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. addStartSizeGradient(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. removeStartSizeGradient(gradient: number): IParticleSystem;
  60580. /**
  60581. * Not supported by GPUParticleSystem
  60582. * @param gradient defines the gradient to use (between 0 and 1)
  60583. * @param min defines the color remap minimal range
  60584. * @param max defines the color remap maximal range
  60585. * @returns the current particle system
  60586. */
  60587. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60588. /**
  60589. * Not supported by GPUParticleSystem
  60590. * @param gradient defines the gradient to remove
  60591. * @returns the current particle system
  60592. */
  60593. removeColorRemapGradient(): IParticleSystem;
  60594. /**
  60595. * Not supported by GPUParticleSystem
  60596. * @param gradient defines the gradient to use (between 0 and 1)
  60597. * @param min defines the alpha remap minimal range
  60598. * @param max defines the alpha remap maximal range
  60599. * @returns the current particle system
  60600. */
  60601. addAlphaRemapGradient(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. removeAlphaRemapGradient(): IParticleSystem;
  60608. /**
  60609. * Not supported by GPUParticleSystem
  60610. * @param gradient defines the gradient to use (between 0 and 1)
  60611. * @param color defines the color to affect to the specified gradient
  60612. * @returns the current particle system
  60613. */
  60614. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60615. /**
  60616. * Not supported by GPUParticleSystem
  60617. * @param gradient defines the gradient to remove
  60618. * @returns the current particle system
  60619. */
  60620. removeRampGradient(): IParticleSystem;
  60621. /**
  60622. * Not supported by GPUParticleSystem
  60623. * @returns the list of ramp gradients
  60624. */
  60625. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60626. /**
  60627. * Not supported by GPUParticleSystem
  60628. * Gets or sets a boolean indicating that ramp gradients must be used
  60629. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60630. */
  60631. useRampGradients: boolean;
  60632. /**
  60633. * Not supported by GPUParticleSystem
  60634. * @param gradient defines the gradient to use (between 0 and 1)
  60635. * @param factor defines the life time factor to affect to the specified gradient
  60636. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60637. * @returns the current particle system
  60638. */
  60639. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60640. /**
  60641. * Not supported by GPUParticleSystem
  60642. * @param gradient defines the gradient to remove
  60643. * @returns the current particle system
  60644. */
  60645. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60646. /**
  60647. * Instantiates a GPU particle system.
  60648. * 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.
  60649. * @param name The name of the particle system
  60650. * @param options The options used to create the system
  60651. * @param scene The scene the particle system belongs to
  60652. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60653. */
  60654. constructor(name: string, options: Partial<{
  60655. capacity: number;
  60656. randomTextureSize: number;
  60657. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60658. protected _reset(): void;
  60659. private _createUpdateVAO;
  60660. private _createRenderVAO;
  60661. private _initialize;
  60662. /** @hidden */
  60663. _recreateUpdateEffect(): void;
  60664. /** @hidden */
  60665. _recreateRenderEffect(): void;
  60666. /**
  60667. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60668. * @param preWarm defines if we are in the pre-warmimg phase
  60669. */
  60670. animate(preWarm?: boolean): void;
  60671. private _createFactorGradientTexture;
  60672. private _createSizeGradientTexture;
  60673. private _createAngularSpeedGradientTexture;
  60674. private _createVelocityGradientTexture;
  60675. private _createLimitVelocityGradientTexture;
  60676. private _createDragGradientTexture;
  60677. private _createColorGradientTexture;
  60678. /**
  60679. * Renders the particle system in its current state
  60680. * @param preWarm defines if the system should only update the particles but not render them
  60681. * @returns the current number of particles
  60682. */
  60683. render(preWarm?: boolean): number;
  60684. /**
  60685. * Rebuilds the particle system
  60686. */
  60687. rebuild(): void;
  60688. private _releaseBuffers;
  60689. private _releaseVAOs;
  60690. /**
  60691. * Disposes the particle system and free the associated resources
  60692. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  60693. */
  60694. dispose(disposeTexture?: boolean): void;
  60695. /**
  60696. * Clones the particle system.
  60697. * @param name The name of the cloned object
  60698. * @param newEmitter The new emitter to use
  60699. * @returns the cloned particle system
  60700. */
  60701. clone(name: string, newEmitter: any): GPUParticleSystem;
  60702. /**
  60703. * Serializes the particle system to a JSON object.
  60704. * @returns the JSON object
  60705. */
  60706. serialize(): any;
  60707. /**
  60708. * Parses a JSON object to create a GPU particle system.
  60709. * @param parsedParticleSystem The JSON object to parse
  60710. * @param scene The scene to create the particle system in
  60711. * @param rootUrl The root url to use to load external dependencies like texture
  60712. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  60713. * @returns the parsed GPU particle system
  60714. */
  60715. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  60716. }
  60717. }
  60718. declare module "babylonjs/Particles/particleSystemSet" {
  60719. import { Nullable } from "babylonjs/types";
  60720. import { Color3 } from "babylonjs/Maths/math.color";
  60721. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60723. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60724. import { Scene, IDisposable } from "babylonjs/scene";
  60725. /**
  60726. * Represents a set of particle systems working together to create a specific effect
  60727. */
  60728. export class ParticleSystemSet implements IDisposable {
  60729. private _emitterCreationOptions;
  60730. private _emitterNode;
  60731. /**
  60732. * Gets the particle system list
  60733. */
  60734. systems: IParticleSystem[];
  60735. /**
  60736. * Gets the emitter node used with this set
  60737. */
  60738. readonly emitterNode: Nullable<TransformNode>;
  60739. /**
  60740. * Creates a new emitter mesh as a sphere
  60741. * @param options defines the options used to create the sphere
  60742. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  60743. * @param scene defines the hosting scene
  60744. */
  60745. setEmitterAsSphere(options: {
  60746. diameter: number;
  60747. segments: number;
  60748. color: Color3;
  60749. }, renderingGroupId: number, scene: Scene): void;
  60750. /**
  60751. * Starts all particle systems of the set
  60752. * @param emitter defines an optional mesh to use as emitter for the particle systems
  60753. */
  60754. start(emitter?: AbstractMesh): void;
  60755. /**
  60756. * Release all associated resources
  60757. */
  60758. dispose(): void;
  60759. /**
  60760. * Serialize the set into a JSON compatible object
  60761. * @returns a JSON compatible representation of the set
  60762. */
  60763. serialize(): any;
  60764. /**
  60765. * Parse a new ParticleSystemSet from a serialized source
  60766. * @param data defines a JSON compatible representation of the set
  60767. * @param scene defines the hosting scene
  60768. * @param gpu defines if we want GPU particles or CPU particles
  60769. * @returns a new ParticleSystemSet
  60770. */
  60771. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  60772. }
  60773. }
  60774. declare module "babylonjs/Particles/particleHelper" {
  60775. import { Nullable } from "babylonjs/types";
  60776. import { Scene } from "babylonjs/scene";
  60777. import { Vector3 } from "babylonjs/Maths/math.vector";
  60778. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60779. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60780. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  60781. /**
  60782. * This class is made for on one-liner static method to help creating particle system set.
  60783. */
  60784. export class ParticleHelper {
  60785. /**
  60786. * Gets or sets base Assets URL
  60787. */
  60788. static BaseAssetsUrl: string;
  60789. /**
  60790. * Create a default particle system that you can tweak
  60791. * @param emitter defines the emitter to use
  60792. * @param capacity defines the system capacity (default is 500 particles)
  60793. * @param scene defines the hosting scene
  60794. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  60795. * @returns the new Particle system
  60796. */
  60797. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  60798. /**
  60799. * This is the main static method (one-liner) of this helper to create different particle systems
  60800. * @param type This string represents the type to the particle system to create
  60801. * @param scene The scene where the particle system should live
  60802. * @param gpu If the system will use gpu
  60803. * @returns the ParticleSystemSet created
  60804. */
  60805. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  60806. /**
  60807. * Static function used to export a particle system to a ParticleSystemSet variable.
  60808. * Please note that the emitter shape is not exported
  60809. * @param systems defines the particle systems to export
  60810. * @returns the created particle system set
  60811. */
  60812. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  60813. }
  60814. }
  60815. declare module "babylonjs/Particles/particleSystemComponent" {
  60816. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60817. import { Effect } from "babylonjs/Materials/effect";
  60818. import "babylonjs/Shaders/particles.vertex";
  60819. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60820. module "babylonjs/Engines/engine" {
  60821. interface Engine {
  60822. /**
  60823. * Create an effect to use with particle systems.
  60824. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  60825. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  60826. * @param uniformsNames defines a list of attribute names
  60827. * @param samplers defines an array of string used to represent textures
  60828. * @param defines defines the string containing the defines to use to compile the shaders
  60829. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  60830. * @param onCompiled defines a function to call when the effect creation is successful
  60831. * @param onError defines a function to call when the effect creation has failed
  60832. * @returns the new Effect
  60833. */
  60834. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  60835. }
  60836. }
  60837. module "babylonjs/Meshes/mesh" {
  60838. interface Mesh {
  60839. /**
  60840. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  60841. * @returns an array of IParticleSystem
  60842. */
  60843. getEmittedParticleSystems(): IParticleSystem[];
  60844. /**
  60845. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  60846. * @returns an array of IParticleSystem
  60847. */
  60848. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  60849. }
  60850. }
  60851. /**
  60852. * @hidden
  60853. */
  60854. export var _IDoNeedToBeInTheBuild: number;
  60855. }
  60856. declare module "babylonjs/Particles/index" {
  60857. export * from "babylonjs/Particles/baseParticleSystem";
  60858. export * from "babylonjs/Particles/EmitterTypes/index";
  60859. export * from "babylonjs/Particles/gpuParticleSystem";
  60860. export * from "babylonjs/Particles/IParticleSystem";
  60861. export * from "babylonjs/Particles/particle";
  60862. export * from "babylonjs/Particles/particleHelper";
  60863. export * from "babylonjs/Particles/particleSystem";
  60864. export * from "babylonjs/Particles/particleSystemComponent";
  60865. export * from "babylonjs/Particles/particleSystemSet";
  60866. export * from "babylonjs/Particles/solidParticle";
  60867. export * from "babylonjs/Particles/solidParticleSystem";
  60868. export * from "babylonjs/Particles/subEmitter";
  60869. }
  60870. declare module "babylonjs/Physics/physicsEngineComponent" {
  60871. import { Nullable } from "babylonjs/types";
  60872. import { Observable, Observer } from "babylonjs/Misc/observable";
  60873. import { Vector3 } from "babylonjs/Maths/math.vector";
  60874. import { Mesh } from "babylonjs/Meshes/mesh";
  60875. import { ISceneComponent } from "babylonjs/sceneComponent";
  60876. import { Scene } from "babylonjs/scene";
  60877. import { Node } from "babylonjs/node";
  60878. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  60879. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60880. module "babylonjs/scene" {
  60881. interface Scene {
  60882. /** @hidden (Backing field) */
  60883. _physicsEngine: Nullable<IPhysicsEngine>;
  60884. /**
  60885. * Gets the current physics engine
  60886. * @returns a IPhysicsEngine or null if none attached
  60887. */
  60888. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  60889. /**
  60890. * Enables physics to the current scene
  60891. * @param gravity defines the scene's gravity for the physics engine
  60892. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  60893. * @return a boolean indicating if the physics engine was initialized
  60894. */
  60895. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  60896. /**
  60897. * Disables and disposes the physics engine associated with the scene
  60898. */
  60899. disablePhysicsEngine(): void;
  60900. /**
  60901. * Gets a boolean indicating if there is an active physics engine
  60902. * @returns a boolean indicating if there is an active physics engine
  60903. */
  60904. isPhysicsEnabled(): boolean;
  60905. /**
  60906. * Deletes a physics compound impostor
  60907. * @param compound defines the compound to delete
  60908. */
  60909. deleteCompoundImpostor(compound: any): void;
  60910. /**
  60911. * An event triggered when physic simulation is about to be run
  60912. */
  60913. onBeforePhysicsObservable: Observable<Scene>;
  60914. /**
  60915. * An event triggered when physic simulation has been done
  60916. */
  60917. onAfterPhysicsObservable: Observable<Scene>;
  60918. }
  60919. }
  60920. module "babylonjs/Meshes/abstractMesh" {
  60921. interface AbstractMesh {
  60922. /** @hidden */
  60923. _physicsImpostor: Nullable<PhysicsImpostor>;
  60924. /**
  60925. * Gets or sets impostor used for physic simulation
  60926. * @see http://doc.babylonjs.com/features/physics_engine
  60927. */
  60928. physicsImpostor: Nullable<PhysicsImpostor>;
  60929. /**
  60930. * Gets the current physics impostor
  60931. * @see http://doc.babylonjs.com/features/physics_engine
  60932. * @returns a physics impostor or null
  60933. */
  60934. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  60935. /** Apply a physic impulse to the mesh
  60936. * @param force defines the force to apply
  60937. * @param contactPoint defines where to apply the force
  60938. * @returns the current mesh
  60939. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  60940. */
  60941. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  60942. /**
  60943. * Creates a physic joint between two meshes
  60944. * @param otherMesh defines the other mesh to use
  60945. * @param pivot1 defines the pivot to use on this mesh
  60946. * @param pivot2 defines the pivot to use on the other mesh
  60947. * @param options defines additional options (can be plugin dependent)
  60948. * @returns the current mesh
  60949. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  60950. */
  60951. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  60952. /** @hidden */
  60953. _disposePhysicsObserver: Nullable<Observer<Node>>;
  60954. }
  60955. }
  60956. /**
  60957. * Defines the physics engine scene component responsible to manage a physics engine
  60958. */
  60959. export class PhysicsEngineSceneComponent implements ISceneComponent {
  60960. /**
  60961. * The component name helpful to identify the component in the list of scene components.
  60962. */
  60963. readonly name: string;
  60964. /**
  60965. * The scene the component belongs to.
  60966. */
  60967. scene: Scene;
  60968. /**
  60969. * Creates a new instance of the component for the given scene
  60970. * @param scene Defines the scene to register the component in
  60971. */
  60972. constructor(scene: Scene);
  60973. /**
  60974. * Registers the component in a given scene
  60975. */
  60976. register(): void;
  60977. /**
  60978. * Rebuilds the elements related to this component in case of
  60979. * context lost for instance.
  60980. */
  60981. rebuild(): void;
  60982. /**
  60983. * Disposes the component and the associated ressources
  60984. */
  60985. dispose(): void;
  60986. }
  60987. }
  60988. declare module "babylonjs/Physics/physicsHelper" {
  60989. import { Nullable } from "babylonjs/types";
  60990. import { Vector3 } from "babylonjs/Maths/math.vector";
  60991. import { Mesh } from "babylonjs/Meshes/mesh";
  60992. import { Scene } from "babylonjs/scene";
  60993. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60994. /**
  60995. * A helper for physics simulations
  60996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60997. */
  60998. export class PhysicsHelper {
  60999. private _scene;
  61000. private _physicsEngine;
  61001. /**
  61002. * Initializes the Physics helper
  61003. * @param scene Babylon.js scene
  61004. */
  61005. constructor(scene: Scene);
  61006. /**
  61007. * Applies a radial explosion impulse
  61008. * @param origin the origin of the explosion
  61009. * @param radiusOrEventOptions the radius or the options of radial explosion
  61010. * @param strength the explosion strength
  61011. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61012. * @returns A physics radial explosion event, or null
  61013. */
  61014. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61015. /**
  61016. * Applies a radial explosion force
  61017. * @param origin the origin of the explosion
  61018. * @param radiusOrEventOptions the radius or the options of radial explosion
  61019. * @param strength the explosion strength
  61020. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61021. * @returns A physics radial explosion event, or null
  61022. */
  61023. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61024. /**
  61025. * Creates a gravitational field
  61026. * @param origin the origin of the explosion
  61027. * @param radiusOrEventOptions the radius or the options of radial explosion
  61028. * @param strength the explosion strength
  61029. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61030. * @returns A physics gravitational field event, or null
  61031. */
  61032. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61033. /**
  61034. * Creates a physics updraft event
  61035. * @param origin the origin of the updraft
  61036. * @param radiusOrEventOptions the radius or the options of the updraft
  61037. * @param strength the strength of the updraft
  61038. * @param height the height of the updraft
  61039. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61040. * @returns A physics updraft event, or null
  61041. */
  61042. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61043. /**
  61044. * Creates a physics vortex event
  61045. * @param origin the of the vortex
  61046. * @param radiusOrEventOptions the radius or the options of the vortex
  61047. * @param strength the strength of the vortex
  61048. * @param height the height of the vortex
  61049. * @returns a Physics vortex event, or null
  61050. * A physics vortex event or null
  61051. */
  61052. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61053. }
  61054. /**
  61055. * Represents a physics radial explosion event
  61056. */
  61057. class PhysicsRadialExplosionEvent {
  61058. private _scene;
  61059. private _options;
  61060. private _sphere;
  61061. private _dataFetched;
  61062. /**
  61063. * Initializes a radial explosioin event
  61064. * @param _scene BabylonJS scene
  61065. * @param _options The options for the vortex event
  61066. */
  61067. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61068. /**
  61069. * Returns the data related to the radial explosion event (sphere).
  61070. * @returns The radial explosion event data
  61071. */
  61072. getData(): PhysicsRadialExplosionEventData;
  61073. /**
  61074. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61075. * @param impostor A physics imposter
  61076. * @param origin the origin of the explosion
  61077. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61078. */
  61079. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61080. /**
  61081. * Triggers affecterd impostors callbacks
  61082. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61083. */
  61084. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61085. /**
  61086. * Disposes the sphere.
  61087. * @param force Specifies if the sphere should be disposed by force
  61088. */
  61089. dispose(force?: boolean): void;
  61090. /*** Helpers ***/
  61091. private _prepareSphere;
  61092. private _intersectsWithSphere;
  61093. }
  61094. /**
  61095. * Represents a gravitational field event
  61096. */
  61097. class PhysicsGravitationalFieldEvent {
  61098. private _physicsHelper;
  61099. private _scene;
  61100. private _origin;
  61101. private _options;
  61102. private _tickCallback;
  61103. private _sphere;
  61104. private _dataFetched;
  61105. /**
  61106. * Initializes the physics gravitational field event
  61107. * @param _physicsHelper A physics helper
  61108. * @param _scene BabylonJS scene
  61109. * @param _origin The origin position of the gravitational field event
  61110. * @param _options The options for the vortex event
  61111. */
  61112. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61113. /**
  61114. * Returns the data related to the gravitational field event (sphere).
  61115. * @returns A gravitational field event
  61116. */
  61117. getData(): PhysicsGravitationalFieldEventData;
  61118. /**
  61119. * Enables the gravitational field.
  61120. */
  61121. enable(): void;
  61122. /**
  61123. * Disables the gravitational field.
  61124. */
  61125. disable(): void;
  61126. /**
  61127. * Disposes the sphere.
  61128. * @param force The force to dispose from the gravitational field event
  61129. */
  61130. dispose(force?: boolean): void;
  61131. private _tick;
  61132. }
  61133. /**
  61134. * Represents a physics updraft event
  61135. */
  61136. class PhysicsUpdraftEvent {
  61137. private _scene;
  61138. private _origin;
  61139. private _options;
  61140. private _physicsEngine;
  61141. private _originTop;
  61142. private _originDirection;
  61143. private _tickCallback;
  61144. private _cylinder;
  61145. private _cylinderPosition;
  61146. private _dataFetched;
  61147. /**
  61148. * Initializes the physics updraft event
  61149. * @param _scene BabylonJS scene
  61150. * @param _origin The origin position of the updraft
  61151. * @param _options The options for the updraft event
  61152. */
  61153. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61154. /**
  61155. * Returns the data related to the updraft event (cylinder).
  61156. * @returns A physics updraft event
  61157. */
  61158. getData(): PhysicsUpdraftEventData;
  61159. /**
  61160. * Enables the updraft.
  61161. */
  61162. enable(): void;
  61163. /**
  61164. * Disables the updraft.
  61165. */
  61166. disable(): void;
  61167. /**
  61168. * Disposes the cylinder.
  61169. * @param force Specifies if the updraft should be disposed by force
  61170. */
  61171. dispose(force?: boolean): void;
  61172. private getImpostorHitData;
  61173. private _tick;
  61174. /*** Helpers ***/
  61175. private _prepareCylinder;
  61176. private _intersectsWithCylinder;
  61177. }
  61178. /**
  61179. * Represents a physics vortex event
  61180. */
  61181. class PhysicsVortexEvent {
  61182. private _scene;
  61183. private _origin;
  61184. private _options;
  61185. private _physicsEngine;
  61186. private _originTop;
  61187. private _tickCallback;
  61188. private _cylinder;
  61189. private _cylinderPosition;
  61190. private _dataFetched;
  61191. /**
  61192. * Initializes the physics vortex event
  61193. * @param _scene The BabylonJS scene
  61194. * @param _origin The origin position of the vortex
  61195. * @param _options The options for the vortex event
  61196. */
  61197. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61198. /**
  61199. * Returns the data related to the vortex event (cylinder).
  61200. * @returns The physics vortex event data
  61201. */
  61202. getData(): PhysicsVortexEventData;
  61203. /**
  61204. * Enables the vortex.
  61205. */
  61206. enable(): void;
  61207. /**
  61208. * Disables the cortex.
  61209. */
  61210. disable(): void;
  61211. /**
  61212. * Disposes the sphere.
  61213. * @param force
  61214. */
  61215. dispose(force?: boolean): void;
  61216. private getImpostorHitData;
  61217. private _tick;
  61218. /*** Helpers ***/
  61219. private _prepareCylinder;
  61220. private _intersectsWithCylinder;
  61221. }
  61222. /**
  61223. * Options fot the radial explosion event
  61224. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61225. */
  61226. export class PhysicsRadialExplosionEventOptions {
  61227. /**
  61228. * The radius of the sphere for the radial explosion.
  61229. */
  61230. radius: number;
  61231. /**
  61232. * The strenth of the explosion.
  61233. */
  61234. strength: number;
  61235. /**
  61236. * The strenght of the force in correspondence to the distance of the affected object
  61237. */
  61238. falloff: PhysicsRadialImpulseFalloff;
  61239. /**
  61240. * Sphere options for the radial explosion.
  61241. */
  61242. sphere: {
  61243. segments: number;
  61244. diameter: number;
  61245. };
  61246. /**
  61247. * Sphere options for the radial explosion.
  61248. */
  61249. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61250. }
  61251. /**
  61252. * Options fot the updraft event
  61253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61254. */
  61255. export class PhysicsUpdraftEventOptions {
  61256. /**
  61257. * The radius of the cylinder for the vortex
  61258. */
  61259. radius: number;
  61260. /**
  61261. * The strenth of the updraft.
  61262. */
  61263. strength: number;
  61264. /**
  61265. * The height of the cylinder for the updraft.
  61266. */
  61267. height: number;
  61268. /**
  61269. * The mode for the the updraft.
  61270. */
  61271. updraftMode: PhysicsUpdraftMode;
  61272. }
  61273. /**
  61274. * Options fot the vortex event
  61275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61276. */
  61277. export class PhysicsVortexEventOptions {
  61278. /**
  61279. * The radius of the cylinder for the vortex
  61280. */
  61281. radius: number;
  61282. /**
  61283. * The strenth of the vortex.
  61284. */
  61285. strength: number;
  61286. /**
  61287. * The height of the cylinder for the vortex.
  61288. */
  61289. height: number;
  61290. /**
  61291. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61292. */
  61293. centripetalForceThreshold: number;
  61294. /**
  61295. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61296. */
  61297. centripetalForceMultiplier: number;
  61298. /**
  61299. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61300. */
  61301. centrifugalForceMultiplier: number;
  61302. /**
  61303. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61304. */
  61305. updraftForceMultiplier: number;
  61306. }
  61307. /**
  61308. * The strenght of the force in correspondence to the distance of the affected object
  61309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61310. */
  61311. export enum PhysicsRadialImpulseFalloff {
  61312. /** Defines that impulse is constant in strength across it's whole radius */
  61313. Constant = 0,
  61314. /** Defines that impulse gets weaker if it's further from the origin */
  61315. Linear = 1
  61316. }
  61317. /**
  61318. * The strength of the force in correspondence to the distance of the affected object
  61319. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61320. */
  61321. export enum PhysicsUpdraftMode {
  61322. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  61323. Center = 0,
  61324. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  61325. Perpendicular = 1
  61326. }
  61327. /**
  61328. * Interface for a physics hit data
  61329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61330. */
  61331. export interface PhysicsHitData {
  61332. /**
  61333. * The force applied at the contact point
  61334. */
  61335. force: Vector3;
  61336. /**
  61337. * The contact point
  61338. */
  61339. contactPoint: Vector3;
  61340. /**
  61341. * The distance from the origin to the contact point
  61342. */
  61343. distanceFromOrigin: number;
  61344. }
  61345. /**
  61346. * Interface for radial explosion event data
  61347. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61348. */
  61349. export interface PhysicsRadialExplosionEventData {
  61350. /**
  61351. * A sphere used for the radial explosion event
  61352. */
  61353. sphere: Mesh;
  61354. }
  61355. /**
  61356. * Interface for gravitational field event data
  61357. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61358. */
  61359. export interface PhysicsGravitationalFieldEventData {
  61360. /**
  61361. * A sphere mesh used for the gravitational field event
  61362. */
  61363. sphere: Mesh;
  61364. }
  61365. /**
  61366. * Interface for updraft event data
  61367. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61368. */
  61369. export interface PhysicsUpdraftEventData {
  61370. /**
  61371. * A cylinder used for the updraft event
  61372. */
  61373. cylinder: Mesh;
  61374. }
  61375. /**
  61376. * Interface for vortex event data
  61377. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61378. */
  61379. export interface PhysicsVortexEventData {
  61380. /**
  61381. * A cylinder used for the vortex event
  61382. */
  61383. cylinder: Mesh;
  61384. }
  61385. /**
  61386. * Interface for an affected physics impostor
  61387. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61388. */
  61389. export interface PhysicsAffectedImpostorWithData {
  61390. /**
  61391. * The impostor affected by the effect
  61392. */
  61393. impostor: PhysicsImpostor;
  61394. /**
  61395. * The data about the hit/horce from the explosion
  61396. */
  61397. hitData: PhysicsHitData;
  61398. }
  61399. }
  61400. declare module "babylonjs/Physics/Plugins/index" {
  61401. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  61402. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  61403. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  61404. }
  61405. declare module "babylonjs/Physics/index" {
  61406. export * from "babylonjs/Physics/IPhysicsEngine";
  61407. export * from "babylonjs/Physics/physicsEngine";
  61408. export * from "babylonjs/Physics/physicsEngineComponent";
  61409. export * from "babylonjs/Physics/physicsHelper";
  61410. export * from "babylonjs/Physics/physicsImpostor";
  61411. export * from "babylonjs/Physics/physicsJoint";
  61412. export * from "babylonjs/Physics/Plugins/index";
  61413. }
  61414. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  61415. /** @hidden */
  61416. export var blackAndWhitePixelShader: {
  61417. name: string;
  61418. shader: string;
  61419. };
  61420. }
  61421. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  61422. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61423. import { Camera } from "babylonjs/Cameras/camera";
  61424. import { Engine } from "babylonjs/Engines/engine";
  61425. import "babylonjs/Shaders/blackAndWhite.fragment";
  61426. /**
  61427. * Post process used to render in black and white
  61428. */
  61429. export class BlackAndWhitePostProcess extends PostProcess {
  61430. /**
  61431. * Linear about to convert he result to black and white (default: 1)
  61432. */
  61433. degree: number;
  61434. /**
  61435. * Creates a black and white post process
  61436. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  61437. * @param name The name of the effect.
  61438. * @param options The required width/height ratio to downsize to before computing the render pass.
  61439. * @param camera The camera to apply the render pass to.
  61440. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61441. * @param engine The engine which the post process will be applied. (default: current engine)
  61442. * @param reusable If the post process can be reused on the same frame. (default: false)
  61443. */
  61444. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61445. }
  61446. }
  61447. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  61448. import { Nullable } from "babylonjs/types";
  61449. import { Camera } from "babylonjs/Cameras/camera";
  61450. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61451. import { Engine } from "babylonjs/Engines/engine";
  61452. /**
  61453. * This represents a set of one or more post processes in Babylon.
  61454. * A post process can be used to apply a shader to a texture after it is rendered.
  61455. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61456. */
  61457. export class PostProcessRenderEffect {
  61458. private _postProcesses;
  61459. private _getPostProcesses;
  61460. private _singleInstance;
  61461. private _cameras;
  61462. private _indicesForCamera;
  61463. /**
  61464. * Name of the effect
  61465. * @hidden
  61466. */
  61467. _name: string;
  61468. /**
  61469. * Instantiates a post process render effect.
  61470. * A post process can be used to apply a shader to a texture after it is rendered.
  61471. * @param engine The engine the effect is tied to
  61472. * @param name The name of the effect
  61473. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  61474. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  61475. */
  61476. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  61477. /**
  61478. * Checks if all the post processes in the effect are supported.
  61479. */
  61480. readonly isSupported: boolean;
  61481. /**
  61482. * Updates the current state of the effect
  61483. * @hidden
  61484. */
  61485. _update(): void;
  61486. /**
  61487. * Attaches the effect on cameras
  61488. * @param cameras The camera to attach to.
  61489. * @hidden
  61490. */
  61491. _attachCameras(cameras: Camera): void;
  61492. /**
  61493. * Attaches the effect on cameras
  61494. * @param cameras The camera to attach to.
  61495. * @hidden
  61496. */
  61497. _attachCameras(cameras: Camera[]): void;
  61498. /**
  61499. * Detaches the effect on cameras
  61500. * @param cameras The camera to detatch from.
  61501. * @hidden
  61502. */
  61503. _detachCameras(cameras: Camera): void;
  61504. /**
  61505. * Detatches the effect on cameras
  61506. * @param cameras The camera to detatch from.
  61507. * @hidden
  61508. */
  61509. _detachCameras(cameras: Camera[]): void;
  61510. /**
  61511. * Enables the effect on given cameras
  61512. * @param cameras The camera to enable.
  61513. * @hidden
  61514. */
  61515. _enable(cameras: Camera): void;
  61516. /**
  61517. * Enables the effect on given cameras
  61518. * @param cameras The camera to enable.
  61519. * @hidden
  61520. */
  61521. _enable(cameras: Nullable<Camera[]>): void;
  61522. /**
  61523. * Disables the effect on the given cameras
  61524. * @param cameras The camera to disable.
  61525. * @hidden
  61526. */
  61527. _disable(cameras: Camera): void;
  61528. /**
  61529. * Disables the effect on the given cameras
  61530. * @param cameras The camera to disable.
  61531. * @hidden
  61532. */
  61533. _disable(cameras: Nullable<Camera[]>): void;
  61534. /**
  61535. * Gets a list of the post processes contained in the effect.
  61536. * @param camera The camera to get the post processes on.
  61537. * @returns The list of the post processes in the effect.
  61538. */
  61539. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61540. }
  61541. }
  61542. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  61543. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61544. /** @hidden */
  61545. export var extractHighlightsPixelShader: {
  61546. name: string;
  61547. shader: string;
  61548. };
  61549. }
  61550. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  61551. import { Nullable } from "babylonjs/types";
  61552. import { Camera } from "babylonjs/Cameras/camera";
  61553. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61554. import { Engine } from "babylonjs/Engines/engine";
  61555. import "babylonjs/Shaders/extractHighlights.fragment";
  61556. /**
  61557. * 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.
  61558. */
  61559. export class ExtractHighlightsPostProcess extends PostProcess {
  61560. /**
  61561. * The luminance threshold, pixels below this value will be set to black.
  61562. */
  61563. threshold: number;
  61564. /** @hidden */
  61565. _exposure: number;
  61566. /**
  61567. * Post process which has the input texture to be used when performing highlight extraction
  61568. * @hidden
  61569. */
  61570. _inputPostProcess: Nullable<PostProcess>;
  61571. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61572. }
  61573. }
  61574. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  61575. /** @hidden */
  61576. export var bloomMergePixelShader: {
  61577. name: string;
  61578. shader: string;
  61579. };
  61580. }
  61581. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  61582. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61583. import { Nullable } from "babylonjs/types";
  61584. import { Engine } from "babylonjs/Engines/engine";
  61585. import { Camera } from "babylonjs/Cameras/camera";
  61586. import "babylonjs/Shaders/bloomMerge.fragment";
  61587. /**
  61588. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61589. */
  61590. export class BloomMergePostProcess extends PostProcess {
  61591. /** Weight of the bloom to be added to the original input. */
  61592. weight: number;
  61593. /**
  61594. * Creates a new instance of @see BloomMergePostProcess
  61595. * @param name The name of the effect.
  61596. * @param originalFromInput Post process which's input will be used for the merge.
  61597. * @param blurred Blurred highlights post process which's output will be used.
  61598. * @param weight Weight of the bloom to be added to the original input.
  61599. * @param options The required width/height ratio to downsize to before computing the render pass.
  61600. * @param camera The camera to apply the render pass to.
  61601. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61602. * @param engine The engine which the post process will be applied. (default: current engine)
  61603. * @param reusable If the post process can be reused on the same frame. (default: false)
  61604. * @param textureType Type of textures used when performing the post process. (default: 0)
  61605. * @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)
  61606. */
  61607. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  61608. /** Weight of the bloom to be added to the original input. */
  61609. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61610. }
  61611. }
  61612. declare module "babylonjs/PostProcesses/bloomEffect" {
  61613. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61614. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61615. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61616. import { Camera } from "babylonjs/Cameras/camera";
  61617. import { Scene } from "babylonjs/scene";
  61618. /**
  61619. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  61620. */
  61621. export class BloomEffect extends PostProcessRenderEffect {
  61622. private bloomScale;
  61623. /**
  61624. * @hidden Internal
  61625. */
  61626. _effects: Array<PostProcess>;
  61627. /**
  61628. * @hidden Internal
  61629. */
  61630. _downscale: ExtractHighlightsPostProcess;
  61631. private _blurX;
  61632. private _blurY;
  61633. private _merge;
  61634. /**
  61635. * The luminance threshold to find bright areas of the image to bloom.
  61636. */
  61637. threshold: number;
  61638. /**
  61639. * The strength of the bloom.
  61640. */
  61641. weight: number;
  61642. /**
  61643. * Specifies the size of the bloom blur kernel, relative to the final output size
  61644. */
  61645. kernel: number;
  61646. /**
  61647. * Creates a new instance of @see BloomEffect
  61648. * @param scene The scene the effect belongs to.
  61649. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  61650. * @param bloomKernel The size of the kernel to be used when applying the blur.
  61651. * @param bloomWeight The the strength of bloom.
  61652. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61653. * @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)
  61654. */
  61655. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  61656. /**
  61657. * Disposes each of the internal effects for a given camera.
  61658. * @param camera The camera to dispose the effect on.
  61659. */
  61660. disposeEffects(camera: Camera): void;
  61661. /**
  61662. * @hidden Internal
  61663. */
  61664. _updateEffects(): void;
  61665. /**
  61666. * Internal
  61667. * @returns if all the contained post processes are ready.
  61668. * @hidden
  61669. */
  61670. _isReady(): boolean;
  61671. }
  61672. }
  61673. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  61674. /** @hidden */
  61675. export var chromaticAberrationPixelShader: {
  61676. name: string;
  61677. shader: string;
  61678. };
  61679. }
  61680. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  61681. import { Vector2 } from "babylonjs/Maths/math.vector";
  61682. import { Nullable } from "babylonjs/types";
  61683. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61684. import { Camera } from "babylonjs/Cameras/camera";
  61685. import { Engine } from "babylonjs/Engines/engine";
  61686. import "babylonjs/Shaders/chromaticAberration.fragment";
  61687. /**
  61688. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  61689. */
  61690. export class ChromaticAberrationPostProcess extends PostProcess {
  61691. /**
  61692. * The amount of seperation of rgb channels (default: 30)
  61693. */
  61694. aberrationAmount: number;
  61695. /**
  61696. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  61697. */
  61698. radialIntensity: number;
  61699. /**
  61700. * 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))
  61701. */
  61702. direction: Vector2;
  61703. /**
  61704. * 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))
  61705. */
  61706. centerPosition: Vector2;
  61707. /**
  61708. * Creates a new instance ChromaticAberrationPostProcess
  61709. * @param name The name of the effect.
  61710. * @param screenWidth The width of the screen to apply the effect on.
  61711. * @param screenHeight The height of the screen to apply the effect on.
  61712. * @param options The required width/height ratio to downsize to before computing the render pass.
  61713. * @param camera The camera to apply the render pass to.
  61714. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61715. * @param engine The engine which the post process will be applied. (default: current engine)
  61716. * @param reusable If the post process can be reused on the same frame. (default: false)
  61717. * @param textureType Type of textures used when performing the post process. (default: 0)
  61718. * @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)
  61719. */
  61720. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61721. }
  61722. }
  61723. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  61724. /** @hidden */
  61725. export var circleOfConfusionPixelShader: {
  61726. name: string;
  61727. shader: string;
  61728. };
  61729. }
  61730. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  61731. import { Nullable } from "babylonjs/types";
  61732. import { Engine } from "babylonjs/Engines/engine";
  61733. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61734. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61735. import { Camera } from "babylonjs/Cameras/camera";
  61736. import "babylonjs/Shaders/circleOfConfusion.fragment";
  61737. /**
  61738. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  61739. */
  61740. export class CircleOfConfusionPostProcess extends PostProcess {
  61741. /**
  61742. * 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.
  61743. */
  61744. lensSize: number;
  61745. /**
  61746. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61747. */
  61748. fStop: number;
  61749. /**
  61750. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61751. */
  61752. focusDistance: number;
  61753. /**
  61754. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  61755. */
  61756. focalLength: number;
  61757. private _depthTexture;
  61758. /**
  61759. * Creates a new instance CircleOfConfusionPostProcess
  61760. * @param name The name of the effect.
  61761. * @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.
  61762. * @param options The required width/height ratio to downsize to before computing the render pass.
  61763. * @param camera The camera to apply the render pass to.
  61764. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61765. * @param engine The engine which the post process will be applied. (default: current engine)
  61766. * @param reusable If the post process can be reused on the same frame. (default: false)
  61767. * @param textureType Type of textures used when performing the post process. (default: 0)
  61768. * @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)
  61769. */
  61770. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61771. /**
  61772. * 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.
  61773. */
  61774. depthTexture: RenderTargetTexture;
  61775. }
  61776. }
  61777. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  61778. /** @hidden */
  61779. export var colorCorrectionPixelShader: {
  61780. name: string;
  61781. shader: string;
  61782. };
  61783. }
  61784. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  61785. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61786. import { Engine } from "babylonjs/Engines/engine";
  61787. import { Camera } from "babylonjs/Cameras/camera";
  61788. import "babylonjs/Shaders/colorCorrection.fragment";
  61789. /**
  61790. *
  61791. * This post-process allows the modification of rendered colors by using
  61792. * a 'look-up table' (LUT). This effect is also called Color Grading.
  61793. *
  61794. * The object needs to be provided an url to a texture containing the color
  61795. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  61796. * Use an image editing software to tweak the LUT to match your needs.
  61797. *
  61798. * For an example of a color LUT, see here:
  61799. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  61800. * For explanations on color grading, see here:
  61801. * @see http://udn.epicgames.com/Three/ColorGrading.html
  61802. *
  61803. */
  61804. export class ColorCorrectionPostProcess extends PostProcess {
  61805. private _colorTableTexture;
  61806. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61807. }
  61808. }
  61809. declare module "babylonjs/Shaders/convolution.fragment" {
  61810. /** @hidden */
  61811. export var convolutionPixelShader: {
  61812. name: string;
  61813. shader: string;
  61814. };
  61815. }
  61816. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  61817. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61818. import { Nullable } from "babylonjs/types";
  61819. import { Camera } from "babylonjs/Cameras/camera";
  61820. import { Engine } from "babylonjs/Engines/engine";
  61821. import "babylonjs/Shaders/convolution.fragment";
  61822. /**
  61823. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  61824. * input texture to perform effects such as edge detection or sharpening
  61825. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61826. */
  61827. export class ConvolutionPostProcess extends PostProcess {
  61828. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61829. kernel: number[];
  61830. /**
  61831. * Creates a new instance ConvolutionPostProcess
  61832. * @param name The name of the effect.
  61833. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  61834. * @param options The required width/height ratio to downsize to before computing the render pass.
  61835. * @param camera The camera to apply the render pass to.
  61836. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61837. * @param engine The engine which the post process will be applied. (default: current engine)
  61838. * @param reusable If the post process can be reused on the same frame. (default: false)
  61839. * @param textureType Type of textures used when performing the post process. (default: 0)
  61840. */
  61841. constructor(name: string,
  61842. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61843. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61844. /**
  61845. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61846. */
  61847. static EdgeDetect0Kernel: number[];
  61848. /**
  61849. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61850. */
  61851. static EdgeDetect1Kernel: number[];
  61852. /**
  61853. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61854. */
  61855. static EdgeDetect2Kernel: number[];
  61856. /**
  61857. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61858. */
  61859. static SharpenKernel: number[];
  61860. /**
  61861. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61862. */
  61863. static EmbossKernel: number[];
  61864. /**
  61865. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61866. */
  61867. static GaussianKernel: number[];
  61868. }
  61869. }
  61870. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  61871. import { Nullable } from "babylonjs/types";
  61872. import { Vector2 } from "babylonjs/Maths/math.vector";
  61873. import { Camera } from "babylonjs/Cameras/camera";
  61874. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61875. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61876. import { Engine } from "babylonjs/Engines/engine";
  61877. import { Scene } from "babylonjs/scene";
  61878. /**
  61879. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  61880. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  61881. * based on samples that have a large difference in distance than the center pixel.
  61882. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  61883. */
  61884. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  61885. direction: Vector2;
  61886. /**
  61887. * Creates a new instance CircleOfConfusionPostProcess
  61888. * @param name The name of the effect.
  61889. * @param scene The scene the effect belongs to.
  61890. * @param direction The direction the blur should be applied.
  61891. * @param kernel The size of the kernel used to blur.
  61892. * @param options The required width/height ratio to downsize to before computing the render pass.
  61893. * @param camera The camera to apply the render pass to.
  61894. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  61895. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  61896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61897. * @param engine The engine which the post process will be applied. (default: current engine)
  61898. * @param reusable If the post process can be reused on the same frame. (default: false)
  61899. * @param textureType Type of textures used when performing the post process. (default: 0)
  61900. * @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)
  61901. */
  61902. 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);
  61903. }
  61904. }
  61905. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  61906. /** @hidden */
  61907. export var depthOfFieldMergePixelShader: {
  61908. name: string;
  61909. shader: string;
  61910. };
  61911. }
  61912. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  61913. import { Nullable } from "babylonjs/types";
  61914. import { Camera } from "babylonjs/Cameras/camera";
  61915. import { Effect } from "babylonjs/Materials/effect";
  61916. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61917. import { Engine } from "babylonjs/Engines/engine";
  61918. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  61919. /**
  61920. * Options to be set when merging outputs from the default pipeline.
  61921. */
  61922. export class DepthOfFieldMergePostProcessOptions {
  61923. /**
  61924. * The original image to merge on top of
  61925. */
  61926. originalFromInput: PostProcess;
  61927. /**
  61928. * Parameters to perform the merge of the depth of field effect
  61929. */
  61930. depthOfField?: {
  61931. circleOfConfusion: PostProcess;
  61932. blurSteps: Array<PostProcess>;
  61933. };
  61934. /**
  61935. * Parameters to perform the merge of bloom effect
  61936. */
  61937. bloom?: {
  61938. blurred: PostProcess;
  61939. weight: number;
  61940. };
  61941. }
  61942. /**
  61943. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61944. */
  61945. export class DepthOfFieldMergePostProcess extends PostProcess {
  61946. private blurSteps;
  61947. /**
  61948. * Creates a new instance of DepthOfFieldMergePostProcess
  61949. * @param name The name of the effect.
  61950. * @param originalFromInput Post process which's input will be used for the merge.
  61951. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  61952. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  61953. * @param options The required width/height ratio to downsize to before computing the render pass.
  61954. * @param camera The camera to apply the render pass to.
  61955. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61956. * @param engine The engine which the post process will be applied. (default: current engine)
  61957. * @param reusable If the post process can be reused on the same frame. (default: false)
  61958. * @param textureType Type of textures used when performing the post process. (default: 0)
  61959. * @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)
  61960. */
  61961. 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);
  61962. /**
  61963. * Updates the effect with the current post process compile time values and recompiles the shader.
  61964. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  61965. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  61966. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  61967. * @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
  61968. * @param onCompiled Called when the shader has been compiled.
  61969. * @param onError Called if there is an error when compiling a shader.
  61970. */
  61971. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  61972. }
  61973. }
  61974. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  61975. import { Nullable } from "babylonjs/types";
  61976. import { Camera } from "babylonjs/Cameras/camera";
  61977. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61978. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61979. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61980. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  61981. import { Scene } from "babylonjs/scene";
  61982. /**
  61983. * Specifies the level of max blur that should be applied when using the depth of field effect
  61984. */
  61985. export enum DepthOfFieldEffectBlurLevel {
  61986. /**
  61987. * Subtle blur
  61988. */
  61989. Low = 0,
  61990. /**
  61991. * Medium blur
  61992. */
  61993. Medium = 1,
  61994. /**
  61995. * Large blur
  61996. */
  61997. High = 2
  61998. }
  61999. /**
  62000. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62001. */
  62002. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62003. private _circleOfConfusion;
  62004. /**
  62005. * @hidden Internal, blurs from high to low
  62006. */
  62007. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62008. private _depthOfFieldBlurY;
  62009. private _dofMerge;
  62010. /**
  62011. * @hidden Internal post processes in depth of field effect
  62012. */
  62013. _effects: Array<PostProcess>;
  62014. /**
  62015. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62016. */
  62017. focalLength: number;
  62018. /**
  62019. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62020. */
  62021. fStop: number;
  62022. /**
  62023. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62024. */
  62025. focusDistance: number;
  62026. /**
  62027. * 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.
  62028. */
  62029. lensSize: number;
  62030. /**
  62031. * Creates a new instance DepthOfFieldEffect
  62032. * @param scene The scene the effect belongs to.
  62033. * @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.
  62034. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62035. * @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)
  62036. */
  62037. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62038. /**
  62039. * Get the current class name of the current effet
  62040. * @returns "DepthOfFieldEffect"
  62041. */
  62042. getClassName(): string;
  62043. /**
  62044. * 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.
  62045. */
  62046. depthTexture: RenderTargetTexture;
  62047. /**
  62048. * Disposes each of the internal effects for a given camera.
  62049. * @param camera The camera to dispose the effect on.
  62050. */
  62051. disposeEffects(camera: Camera): void;
  62052. /**
  62053. * @hidden Internal
  62054. */
  62055. _updateEffects(): void;
  62056. /**
  62057. * Internal
  62058. * @returns if all the contained post processes are ready.
  62059. * @hidden
  62060. */
  62061. _isReady(): boolean;
  62062. }
  62063. }
  62064. declare module "babylonjs/Shaders/displayPass.fragment" {
  62065. /** @hidden */
  62066. export var displayPassPixelShader: {
  62067. name: string;
  62068. shader: string;
  62069. };
  62070. }
  62071. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  62072. import { Nullable } from "babylonjs/types";
  62073. import { Camera } from "babylonjs/Cameras/camera";
  62074. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62075. import { Engine } from "babylonjs/Engines/engine";
  62076. import "babylonjs/Shaders/displayPass.fragment";
  62077. /**
  62078. * DisplayPassPostProcess which produces an output the same as it's input
  62079. */
  62080. export class DisplayPassPostProcess extends PostProcess {
  62081. /**
  62082. * Creates the DisplayPassPostProcess
  62083. * @param name The name of the effect.
  62084. * @param options The required width/height ratio to downsize to before computing the render pass.
  62085. * @param camera The camera to apply the render pass to.
  62086. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62087. * @param engine The engine which the post process will be applied. (default: current engine)
  62088. * @param reusable If the post process can be reused on the same frame. (default: false)
  62089. */
  62090. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62091. }
  62092. }
  62093. declare module "babylonjs/Shaders/filter.fragment" {
  62094. /** @hidden */
  62095. export var filterPixelShader: {
  62096. name: string;
  62097. shader: string;
  62098. };
  62099. }
  62100. declare module "babylonjs/PostProcesses/filterPostProcess" {
  62101. import { Nullable } from "babylonjs/types";
  62102. import { Matrix } from "babylonjs/Maths/math.vector";
  62103. import { Camera } from "babylonjs/Cameras/camera";
  62104. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62105. import { Engine } from "babylonjs/Engines/engine";
  62106. import "babylonjs/Shaders/filter.fragment";
  62107. /**
  62108. * Applies a kernel filter to the image
  62109. */
  62110. export class FilterPostProcess extends PostProcess {
  62111. /** The matrix to be applied to the image */
  62112. kernelMatrix: Matrix;
  62113. /**
  62114. *
  62115. * @param name The name of the effect.
  62116. * @param kernelMatrix The matrix to be applied to the image
  62117. * @param options The required width/height ratio to downsize to before computing the render pass.
  62118. * @param camera The camera to apply the render pass to.
  62119. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62120. * @param engine The engine which the post process will be applied. (default: current engine)
  62121. * @param reusable If the post process can be reused on the same frame. (default: false)
  62122. */
  62123. constructor(name: string,
  62124. /** The matrix to be applied to the image */
  62125. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62126. }
  62127. }
  62128. declare module "babylonjs/Shaders/fxaa.fragment" {
  62129. /** @hidden */
  62130. export var fxaaPixelShader: {
  62131. name: string;
  62132. shader: string;
  62133. };
  62134. }
  62135. declare module "babylonjs/Shaders/fxaa.vertex" {
  62136. /** @hidden */
  62137. export var fxaaVertexShader: {
  62138. name: string;
  62139. shader: string;
  62140. };
  62141. }
  62142. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  62143. import { Nullable } from "babylonjs/types";
  62144. import { Camera } from "babylonjs/Cameras/camera";
  62145. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62146. import { Engine } from "babylonjs/Engines/engine";
  62147. import "babylonjs/Shaders/fxaa.fragment";
  62148. import "babylonjs/Shaders/fxaa.vertex";
  62149. /**
  62150. * Fxaa post process
  62151. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62152. */
  62153. export class FxaaPostProcess extends PostProcess {
  62154. /** @hidden */
  62155. texelWidth: number;
  62156. /** @hidden */
  62157. texelHeight: number;
  62158. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62159. private _getDefines;
  62160. }
  62161. }
  62162. declare module "babylonjs/Shaders/grain.fragment" {
  62163. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62164. /** @hidden */
  62165. export var grainPixelShader: {
  62166. name: string;
  62167. shader: string;
  62168. };
  62169. }
  62170. declare module "babylonjs/PostProcesses/grainPostProcess" {
  62171. import { Nullable } from "babylonjs/types";
  62172. import { Camera } from "babylonjs/Cameras/camera";
  62173. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62174. import { Engine } from "babylonjs/Engines/engine";
  62175. import "babylonjs/Shaders/grain.fragment";
  62176. /**
  62177. * The GrainPostProcess adds noise to the image at mid luminance levels
  62178. */
  62179. export class GrainPostProcess extends PostProcess {
  62180. /**
  62181. * The intensity of the grain added (default: 30)
  62182. */
  62183. intensity: number;
  62184. /**
  62185. * If the grain should be randomized on every frame
  62186. */
  62187. animated: boolean;
  62188. /**
  62189. * Creates a new instance of @see GrainPostProcess
  62190. * @param name The name of the effect.
  62191. * @param options The required width/height ratio to downsize to before computing the render pass.
  62192. * @param camera The camera to apply the render pass to.
  62193. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62194. * @param engine The engine which the post process will be applied. (default: current engine)
  62195. * @param reusable If the post process can be reused on the same frame. (default: false)
  62196. * @param textureType Type of textures used when performing the post process. (default: 0)
  62197. * @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)
  62198. */
  62199. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62200. }
  62201. }
  62202. declare module "babylonjs/Shaders/highlights.fragment" {
  62203. /** @hidden */
  62204. export var highlightsPixelShader: {
  62205. name: string;
  62206. shader: string;
  62207. };
  62208. }
  62209. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  62210. import { Nullable } from "babylonjs/types";
  62211. import { Camera } from "babylonjs/Cameras/camera";
  62212. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62213. import { Engine } from "babylonjs/Engines/engine";
  62214. import "babylonjs/Shaders/highlights.fragment";
  62215. /**
  62216. * Extracts highlights from the image
  62217. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62218. */
  62219. export class HighlightsPostProcess extends PostProcess {
  62220. /**
  62221. * Extracts highlights from the image
  62222. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62223. * @param name The name of the effect.
  62224. * @param options The required width/height ratio to downsize to before computing the render pass.
  62225. * @param camera The camera to apply the render pass to.
  62226. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62227. * @param engine The engine which the post process will be applied. (default: current engine)
  62228. * @param reusable If the post process can be reused on the same frame. (default: false)
  62229. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62230. */
  62231. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62232. }
  62233. }
  62234. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  62235. /** @hidden */
  62236. export var mrtFragmentDeclaration: {
  62237. name: string;
  62238. shader: string;
  62239. };
  62240. }
  62241. declare module "babylonjs/Shaders/geometry.fragment" {
  62242. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  62243. /** @hidden */
  62244. export var geometryPixelShader: {
  62245. name: string;
  62246. shader: string;
  62247. };
  62248. }
  62249. declare module "babylonjs/Shaders/geometry.vertex" {
  62250. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62251. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62252. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62253. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62254. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62255. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62256. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62257. /** @hidden */
  62258. export var geometryVertexShader: {
  62259. name: string;
  62260. shader: string;
  62261. };
  62262. }
  62263. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  62264. import { Matrix } from "babylonjs/Maths/math.vector";
  62265. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62266. import { Mesh } from "babylonjs/Meshes/mesh";
  62267. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  62268. import { Effect } from "babylonjs/Materials/effect";
  62269. import { Scene } from "babylonjs/scene";
  62270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62271. import "babylonjs/Shaders/geometry.fragment";
  62272. import "babylonjs/Shaders/geometry.vertex";
  62273. /** @hidden */
  62274. interface ISavedTransformationMatrix {
  62275. world: Matrix;
  62276. viewProjection: Matrix;
  62277. }
  62278. /**
  62279. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62280. */
  62281. export class GeometryBufferRenderer {
  62282. /**
  62283. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62284. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62285. */
  62286. static readonly POSITION_TEXTURE_TYPE: number;
  62287. /**
  62288. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62289. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62290. */
  62291. static readonly VELOCITY_TEXTURE_TYPE: number;
  62292. /**
  62293. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62294. * in order to compute objects velocities when enableVelocity is set to "true"
  62295. * @hidden
  62296. */
  62297. _previousTransformationMatrices: {
  62298. [index: number]: ISavedTransformationMatrix;
  62299. };
  62300. /**
  62301. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62302. * in order to compute objects velocities when enableVelocity is set to "true"
  62303. * @hidden
  62304. */
  62305. _previousBonesTransformationMatrices: {
  62306. [index: number]: Float32Array;
  62307. };
  62308. /**
  62309. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62310. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62311. */
  62312. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62313. private _scene;
  62314. private _multiRenderTarget;
  62315. private _ratio;
  62316. private _enablePosition;
  62317. private _enableVelocity;
  62318. private _positionIndex;
  62319. private _velocityIndex;
  62320. protected _effect: Effect;
  62321. protected _cachedDefines: string;
  62322. /**
  62323. * Set the render list (meshes to be rendered) used in the G buffer.
  62324. */
  62325. renderList: Mesh[];
  62326. /**
  62327. * Gets wether or not G buffer are supported by the running hardware.
  62328. * This requires draw buffer supports
  62329. */
  62330. readonly isSupported: boolean;
  62331. /**
  62332. * Returns the index of the given texture type in the G-Buffer textures array
  62333. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62334. * @returns the index of the given texture type in the G-Buffer textures array
  62335. */
  62336. getTextureIndex(textureType: number): number;
  62337. /**
  62338. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62339. */
  62340. /**
  62341. * Sets whether or not objects positions are enabled for the G buffer.
  62342. */
  62343. enablePosition: boolean;
  62344. /**
  62345. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62346. */
  62347. /**
  62348. * Sets wether or not objects velocities are enabled for the G buffer.
  62349. */
  62350. enableVelocity: boolean;
  62351. /**
  62352. * Gets the scene associated with the buffer.
  62353. */
  62354. readonly scene: Scene;
  62355. /**
  62356. * Gets the ratio used by the buffer during its creation.
  62357. * How big is the buffer related to the main canvas.
  62358. */
  62359. readonly ratio: number;
  62360. /** @hidden */
  62361. static _SceneComponentInitialization: (scene: Scene) => void;
  62362. /**
  62363. * Creates a new G Buffer for the scene
  62364. * @param scene The scene the buffer belongs to
  62365. * @param ratio How big is the buffer related to the main canvas.
  62366. */
  62367. constructor(scene: Scene, ratio?: number);
  62368. /**
  62369. * Checks wether everything is ready to render a submesh to the G buffer.
  62370. * @param subMesh the submesh to check readiness for
  62371. * @param useInstances is the mesh drawn using instance or not
  62372. * @returns true if ready otherwise false
  62373. */
  62374. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62375. /**
  62376. * Gets the current underlying G Buffer.
  62377. * @returns the buffer
  62378. */
  62379. getGBuffer(): MultiRenderTarget;
  62380. /**
  62381. * Gets the number of samples used to render the buffer (anti aliasing).
  62382. */
  62383. /**
  62384. * Sets the number of samples used to render the buffer (anti aliasing).
  62385. */
  62386. samples: number;
  62387. /**
  62388. * Disposes the renderer and frees up associated resources.
  62389. */
  62390. dispose(): void;
  62391. protected _createRenderTargets(): void;
  62392. private _copyBonesTransformationMatrices;
  62393. }
  62394. }
  62395. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  62396. import { Nullable } from "babylonjs/types";
  62397. import { Scene } from "babylonjs/scene";
  62398. import { ISceneComponent } from "babylonjs/sceneComponent";
  62399. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  62400. module "babylonjs/scene" {
  62401. interface Scene {
  62402. /** @hidden (Backing field) */
  62403. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62404. /**
  62405. * Gets or Sets the current geometry buffer associated to the scene.
  62406. */
  62407. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62408. /**
  62409. * Enables a GeometryBufferRender and associates it with the scene
  62410. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62411. * @returns the GeometryBufferRenderer
  62412. */
  62413. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62414. /**
  62415. * Disables the GeometryBufferRender associated with the scene
  62416. */
  62417. disableGeometryBufferRenderer(): void;
  62418. }
  62419. }
  62420. /**
  62421. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62422. * in several rendering techniques.
  62423. */
  62424. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62425. /**
  62426. * The component name helpful to identify the component in the list of scene components.
  62427. */
  62428. readonly name: string;
  62429. /**
  62430. * The scene the component belongs to.
  62431. */
  62432. scene: Scene;
  62433. /**
  62434. * Creates a new instance of the component for the given scene
  62435. * @param scene Defines the scene to register the component in
  62436. */
  62437. constructor(scene: Scene);
  62438. /**
  62439. * Registers the component in a given scene
  62440. */
  62441. register(): void;
  62442. /**
  62443. * Rebuilds the elements related to this component in case of
  62444. * context lost for instance.
  62445. */
  62446. rebuild(): void;
  62447. /**
  62448. * Disposes the component and the associated ressources
  62449. */
  62450. dispose(): void;
  62451. private _gatherRenderTargets;
  62452. }
  62453. }
  62454. declare module "babylonjs/Shaders/motionBlur.fragment" {
  62455. /** @hidden */
  62456. export var motionBlurPixelShader: {
  62457. name: string;
  62458. shader: string;
  62459. };
  62460. }
  62461. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  62462. import { Nullable } from "babylonjs/types";
  62463. import { Camera } from "babylonjs/Cameras/camera";
  62464. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62465. import { Scene } from "babylonjs/scene";
  62466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62467. import "babylonjs/Animations/animatable";
  62468. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62469. import "babylonjs/Shaders/motionBlur.fragment";
  62470. import { Engine } from "babylonjs/Engines/engine";
  62471. /**
  62472. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  62473. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  62474. * As an example, all you have to do is to create the post-process:
  62475. * var mb = new BABYLON.MotionBlurPostProcess(
  62476. * 'mb', // The name of the effect.
  62477. * scene, // The scene containing the objects to blur according to their velocity.
  62478. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  62479. * camera // The camera to apply the render pass to.
  62480. * );
  62481. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62482. */
  62483. export class MotionBlurPostProcess extends PostProcess {
  62484. /**
  62485. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62486. */
  62487. motionStrength: number;
  62488. /**
  62489. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62490. */
  62491. /**
  62492. * Sets the number of iterations to be used for motion blur quality
  62493. */
  62494. motionBlurSamples: number;
  62495. private _motionBlurSamples;
  62496. private _geometryBufferRenderer;
  62497. /**
  62498. * Creates a new instance MotionBlurPostProcess
  62499. * @param name The name of the effect.
  62500. * @param scene The scene containing the objects to blur according to their velocity.
  62501. * @param options The required width/height ratio to downsize to before computing the render pass.
  62502. * @param camera The camera to apply the render pass to.
  62503. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62504. * @param engine The engine which the post process will be applied. (default: current engine)
  62505. * @param reusable If the post process can be reused on the same frame. (default: false)
  62506. * @param textureType Type of textures used when performing the post process. (default: 0)
  62507. * @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)
  62508. */
  62509. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62510. /**
  62511. * Excludes the given skinned mesh from computing bones velocities.
  62512. * 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.
  62513. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62514. */
  62515. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62516. /**
  62517. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62518. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62519. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62520. */
  62521. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62522. /**
  62523. * Disposes the post process.
  62524. * @param camera The camera to dispose the post process on.
  62525. */
  62526. dispose(camera?: Camera): void;
  62527. }
  62528. }
  62529. declare module "babylonjs/Shaders/refraction.fragment" {
  62530. /** @hidden */
  62531. export var refractionPixelShader: {
  62532. name: string;
  62533. shader: string;
  62534. };
  62535. }
  62536. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  62537. import { Color3 } from "babylonjs/Maths/math.color";
  62538. import { Camera } from "babylonjs/Cameras/camera";
  62539. import { Texture } from "babylonjs/Materials/Textures/texture";
  62540. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62541. import { Engine } from "babylonjs/Engines/engine";
  62542. import "babylonjs/Shaders/refraction.fragment";
  62543. /**
  62544. * Post process which applies a refractin texture
  62545. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62546. */
  62547. export class RefractionPostProcess extends PostProcess {
  62548. /** the base color of the refraction (used to taint the rendering) */
  62549. color: Color3;
  62550. /** simulated refraction depth */
  62551. depth: number;
  62552. /** the coefficient of the base color (0 to remove base color tainting) */
  62553. colorLevel: number;
  62554. private _refTexture;
  62555. private _ownRefractionTexture;
  62556. /**
  62557. * Gets or sets the refraction texture
  62558. * Please note that you are responsible for disposing the texture if you set it manually
  62559. */
  62560. refractionTexture: Texture;
  62561. /**
  62562. * Initializes the RefractionPostProcess
  62563. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62564. * @param name The name of the effect.
  62565. * @param refractionTextureUrl Url of the refraction texture to use
  62566. * @param color the base color of the refraction (used to taint the rendering)
  62567. * @param depth simulated refraction depth
  62568. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  62569. * @param camera The camera to apply the render pass to.
  62570. * @param options The required width/height ratio to downsize to before computing the render pass.
  62571. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62572. * @param engine The engine which the post process will be applied. (default: current engine)
  62573. * @param reusable If the post process can be reused on the same frame. (default: false)
  62574. */
  62575. constructor(name: string, refractionTextureUrl: string,
  62576. /** the base color of the refraction (used to taint the rendering) */
  62577. color: Color3,
  62578. /** simulated refraction depth */
  62579. depth: number,
  62580. /** the coefficient of the base color (0 to remove base color tainting) */
  62581. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62582. /**
  62583. * Disposes of the post process
  62584. * @param camera Camera to dispose post process on
  62585. */
  62586. dispose(camera: Camera): void;
  62587. }
  62588. }
  62589. declare module "babylonjs/Shaders/sharpen.fragment" {
  62590. /** @hidden */
  62591. export var sharpenPixelShader: {
  62592. name: string;
  62593. shader: string;
  62594. };
  62595. }
  62596. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  62597. import { Nullable } from "babylonjs/types";
  62598. import { Camera } from "babylonjs/Cameras/camera";
  62599. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62600. import "babylonjs/Shaders/sharpen.fragment";
  62601. import { Engine } from "babylonjs/Engines/engine";
  62602. /**
  62603. * The SharpenPostProcess applies a sharpen kernel to every pixel
  62604. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62605. */
  62606. export class SharpenPostProcess extends PostProcess {
  62607. /**
  62608. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  62609. */
  62610. colorAmount: number;
  62611. /**
  62612. * How much sharpness should be applied (default: 0.3)
  62613. */
  62614. edgeAmount: number;
  62615. /**
  62616. * Creates a new instance ConvolutionPostProcess
  62617. * @param name The name of the effect.
  62618. * @param options The required width/height ratio to downsize to before computing the render pass.
  62619. * @param camera The camera to apply the render pass to.
  62620. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62621. * @param engine The engine which the post process will be applied. (default: current engine)
  62622. * @param reusable If the post process can be reused on the same frame. (default: false)
  62623. * @param textureType Type of textures used when performing the post process. (default: 0)
  62624. * @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)
  62625. */
  62626. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62627. }
  62628. }
  62629. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  62630. import { Nullable } from "babylonjs/types";
  62631. import { Camera } from "babylonjs/Cameras/camera";
  62632. import { Engine } from "babylonjs/Engines/engine";
  62633. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62634. import { IInspectable } from "babylonjs/Misc/iInspectable";
  62635. /**
  62636. * PostProcessRenderPipeline
  62637. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62638. */
  62639. export class PostProcessRenderPipeline {
  62640. private engine;
  62641. private _renderEffects;
  62642. private _renderEffectsForIsolatedPass;
  62643. /**
  62644. * List of inspectable custom properties (used by the Inspector)
  62645. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  62646. */
  62647. inspectableCustomProperties: IInspectable[];
  62648. /**
  62649. * @hidden
  62650. */
  62651. protected _cameras: Camera[];
  62652. /** @hidden */
  62653. _name: string;
  62654. /**
  62655. * Gets pipeline name
  62656. */
  62657. readonly name: string;
  62658. /**
  62659. * Initializes a PostProcessRenderPipeline
  62660. * @param engine engine to add the pipeline to
  62661. * @param name name of the pipeline
  62662. */
  62663. constructor(engine: Engine, name: string);
  62664. /**
  62665. * Gets the class name
  62666. * @returns "PostProcessRenderPipeline"
  62667. */
  62668. getClassName(): string;
  62669. /**
  62670. * If all the render effects in the pipeline are supported
  62671. */
  62672. readonly isSupported: boolean;
  62673. /**
  62674. * Adds an effect to the pipeline
  62675. * @param renderEffect the effect to add
  62676. */
  62677. addEffect(renderEffect: PostProcessRenderEffect): void;
  62678. /** @hidden */
  62679. _rebuild(): void;
  62680. /** @hidden */
  62681. _enableEffect(renderEffectName: string, cameras: Camera): void;
  62682. /** @hidden */
  62683. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  62684. /** @hidden */
  62685. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62686. /** @hidden */
  62687. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62688. /** @hidden */
  62689. _attachCameras(cameras: Camera, unique: boolean): void;
  62690. /** @hidden */
  62691. _attachCameras(cameras: Camera[], unique: boolean): void;
  62692. /** @hidden */
  62693. _detachCameras(cameras: Camera): void;
  62694. /** @hidden */
  62695. _detachCameras(cameras: Nullable<Camera[]>): void;
  62696. /** @hidden */
  62697. _update(): void;
  62698. /** @hidden */
  62699. _reset(): void;
  62700. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  62701. /**
  62702. * Disposes of the pipeline
  62703. */
  62704. dispose(): void;
  62705. }
  62706. }
  62707. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  62708. import { Camera } from "babylonjs/Cameras/camera";
  62709. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62710. /**
  62711. * PostProcessRenderPipelineManager class
  62712. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62713. */
  62714. export class PostProcessRenderPipelineManager {
  62715. private _renderPipelines;
  62716. /**
  62717. * Initializes a PostProcessRenderPipelineManager
  62718. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62719. */
  62720. constructor();
  62721. /**
  62722. * Gets the list of supported render pipelines
  62723. */
  62724. readonly supportedPipelines: PostProcessRenderPipeline[];
  62725. /**
  62726. * Adds a pipeline to the manager
  62727. * @param renderPipeline The pipeline to add
  62728. */
  62729. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  62730. /**
  62731. * Attaches a camera to the pipeline
  62732. * @param renderPipelineName The name of the pipeline to attach to
  62733. * @param cameras the camera to attach
  62734. * @param unique if the camera can be attached multiple times to the pipeline
  62735. */
  62736. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  62737. /**
  62738. * Detaches a camera from the pipeline
  62739. * @param renderPipelineName The name of the pipeline to detach from
  62740. * @param cameras the camera to detach
  62741. */
  62742. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  62743. /**
  62744. * Enables an effect by name on a pipeline
  62745. * @param renderPipelineName the name of the pipeline to enable the effect in
  62746. * @param renderEffectName the name of the effect to enable
  62747. * @param cameras the cameras that the effect should be enabled on
  62748. */
  62749. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62750. /**
  62751. * Disables an effect by name on a pipeline
  62752. * @param renderPipelineName the name of the pipeline to disable the effect in
  62753. * @param renderEffectName the name of the effect to disable
  62754. * @param cameras the cameras that the effect should be disabled on
  62755. */
  62756. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62757. /**
  62758. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  62759. */
  62760. update(): void;
  62761. /** @hidden */
  62762. _rebuild(): void;
  62763. /**
  62764. * Disposes of the manager and pipelines
  62765. */
  62766. dispose(): void;
  62767. }
  62768. }
  62769. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  62770. import { ISceneComponent } from "babylonjs/sceneComponent";
  62771. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  62772. import { Scene } from "babylonjs/scene";
  62773. module "babylonjs/scene" {
  62774. interface Scene {
  62775. /** @hidden (Backing field) */
  62776. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62777. /**
  62778. * Gets the postprocess render pipeline manager
  62779. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62780. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62781. */
  62782. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62783. }
  62784. }
  62785. /**
  62786. * Defines the Render Pipeline scene component responsible to rendering pipelines
  62787. */
  62788. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  62789. /**
  62790. * The component name helpfull to identify the component in the list of scene components.
  62791. */
  62792. readonly name: string;
  62793. /**
  62794. * The scene the component belongs to.
  62795. */
  62796. scene: Scene;
  62797. /**
  62798. * Creates a new instance of the component for the given scene
  62799. * @param scene Defines the scene to register the component in
  62800. */
  62801. constructor(scene: Scene);
  62802. /**
  62803. * Registers the component in a given scene
  62804. */
  62805. register(): void;
  62806. /**
  62807. * Rebuilds the elements related to this component in case of
  62808. * context lost for instance.
  62809. */
  62810. rebuild(): void;
  62811. /**
  62812. * Disposes the component and the associated ressources
  62813. */
  62814. dispose(): void;
  62815. private _gatherRenderTargets;
  62816. }
  62817. }
  62818. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  62819. import { Nullable } from "babylonjs/types";
  62820. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62821. import { Camera } from "babylonjs/Cameras/camera";
  62822. import { IDisposable } from "babylonjs/scene";
  62823. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  62824. import { Scene } from "babylonjs/scene";
  62825. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  62826. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62827. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62828. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  62829. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62830. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62831. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  62832. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62833. import { Animation } from "babylonjs/Animations/animation";
  62834. /**
  62835. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  62836. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62837. */
  62838. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62839. private _scene;
  62840. private _camerasToBeAttached;
  62841. /**
  62842. * ID of the sharpen post process,
  62843. */
  62844. private readonly SharpenPostProcessId;
  62845. /**
  62846. * @ignore
  62847. * ID of the image processing post process;
  62848. */
  62849. readonly ImageProcessingPostProcessId: string;
  62850. /**
  62851. * @ignore
  62852. * ID of the Fast Approximate Anti-Aliasing post process;
  62853. */
  62854. readonly FxaaPostProcessId: string;
  62855. /**
  62856. * ID of the chromatic aberration post process,
  62857. */
  62858. private readonly ChromaticAberrationPostProcessId;
  62859. /**
  62860. * ID of the grain post process
  62861. */
  62862. private readonly GrainPostProcessId;
  62863. /**
  62864. * Sharpen post process which will apply a sharpen convolution to enhance edges
  62865. */
  62866. sharpen: SharpenPostProcess;
  62867. private _sharpenEffect;
  62868. private bloom;
  62869. /**
  62870. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  62871. */
  62872. depthOfField: DepthOfFieldEffect;
  62873. /**
  62874. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62875. */
  62876. fxaa: FxaaPostProcess;
  62877. /**
  62878. * Image post processing pass used to perform operations such as tone mapping or color grading.
  62879. */
  62880. imageProcessing: ImageProcessingPostProcess;
  62881. /**
  62882. * Chromatic aberration post process which will shift rgb colors in the image
  62883. */
  62884. chromaticAberration: ChromaticAberrationPostProcess;
  62885. private _chromaticAberrationEffect;
  62886. /**
  62887. * Grain post process which add noise to the image
  62888. */
  62889. grain: GrainPostProcess;
  62890. private _grainEffect;
  62891. /**
  62892. * Glow post process which adds a glow to emissive areas of the image
  62893. */
  62894. private _glowLayer;
  62895. /**
  62896. * Animations which can be used to tweak settings over a period of time
  62897. */
  62898. animations: Animation[];
  62899. private _imageProcessingConfigurationObserver;
  62900. private _sharpenEnabled;
  62901. private _bloomEnabled;
  62902. private _depthOfFieldEnabled;
  62903. private _depthOfFieldBlurLevel;
  62904. private _fxaaEnabled;
  62905. private _imageProcessingEnabled;
  62906. private _defaultPipelineTextureType;
  62907. private _bloomScale;
  62908. private _chromaticAberrationEnabled;
  62909. private _grainEnabled;
  62910. private _buildAllowed;
  62911. /**
  62912. * Gets active scene
  62913. */
  62914. readonly scene: Scene;
  62915. /**
  62916. * Enable or disable the sharpen process from the pipeline
  62917. */
  62918. sharpenEnabled: boolean;
  62919. private _resizeObserver;
  62920. private _hardwareScaleLevel;
  62921. private _bloomKernel;
  62922. /**
  62923. * Specifies the size of the bloom blur kernel, relative to the final output size
  62924. */
  62925. bloomKernel: number;
  62926. /**
  62927. * Specifies the weight of the bloom in the final rendering
  62928. */
  62929. private _bloomWeight;
  62930. /**
  62931. * Specifies the luma threshold for the area that will be blurred by the bloom
  62932. */
  62933. private _bloomThreshold;
  62934. private _hdr;
  62935. /**
  62936. * The strength of the bloom.
  62937. */
  62938. bloomWeight: number;
  62939. /**
  62940. * The strength of the bloom.
  62941. */
  62942. bloomThreshold: number;
  62943. /**
  62944. * The scale of the bloom, lower value will provide better performance.
  62945. */
  62946. bloomScale: number;
  62947. /**
  62948. * Enable or disable the bloom from the pipeline
  62949. */
  62950. bloomEnabled: boolean;
  62951. private _rebuildBloom;
  62952. /**
  62953. * If the depth of field is enabled.
  62954. */
  62955. depthOfFieldEnabled: boolean;
  62956. /**
  62957. * Blur level of the depth of field effect. (Higher blur will effect performance)
  62958. */
  62959. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  62960. /**
  62961. * If the anti aliasing is enabled.
  62962. */
  62963. fxaaEnabled: boolean;
  62964. private _samples;
  62965. /**
  62966. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62967. */
  62968. samples: number;
  62969. /**
  62970. * If image processing is enabled.
  62971. */
  62972. imageProcessingEnabled: boolean;
  62973. /**
  62974. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  62975. */
  62976. glowLayerEnabled: boolean;
  62977. /**
  62978. * Gets the glow layer (or null if not defined)
  62979. */
  62980. readonly glowLayer: Nullable<GlowLayer>;
  62981. /**
  62982. * Enable or disable the chromaticAberration process from the pipeline
  62983. */
  62984. chromaticAberrationEnabled: boolean;
  62985. /**
  62986. * Enable or disable the grain process from the pipeline
  62987. */
  62988. grainEnabled: boolean;
  62989. /**
  62990. * @constructor
  62991. * @param name - The rendering pipeline name (default: "")
  62992. * @param hdr - If high dynamic range textures should be used (default: true)
  62993. * @param scene - The scene linked to this pipeline (default: the last created scene)
  62994. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  62995. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  62996. */
  62997. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  62998. /**
  62999. * Get the class name
  63000. * @returns "DefaultRenderingPipeline"
  63001. */
  63002. getClassName(): string;
  63003. /**
  63004. * Force the compilation of the entire pipeline.
  63005. */
  63006. prepare(): void;
  63007. private _hasCleared;
  63008. private _prevPostProcess;
  63009. private _prevPrevPostProcess;
  63010. private _setAutoClearAndTextureSharing;
  63011. private _depthOfFieldSceneObserver;
  63012. private _buildPipeline;
  63013. private _disposePostProcesses;
  63014. /**
  63015. * Adds a camera to the pipeline
  63016. * @param camera the camera to be added
  63017. */
  63018. addCamera(camera: Camera): void;
  63019. /**
  63020. * Removes a camera from the pipeline
  63021. * @param camera the camera to remove
  63022. */
  63023. removeCamera(camera: Camera): void;
  63024. /**
  63025. * Dispose of the pipeline and stop all post processes
  63026. */
  63027. dispose(): void;
  63028. /**
  63029. * Serialize the rendering pipeline (Used when exporting)
  63030. * @returns the serialized object
  63031. */
  63032. serialize(): any;
  63033. /**
  63034. * Parse the serialized pipeline
  63035. * @param source Source pipeline.
  63036. * @param scene The scene to load the pipeline to.
  63037. * @param rootUrl The URL of the serialized pipeline.
  63038. * @returns An instantiated pipeline from the serialized object.
  63039. */
  63040. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  63041. }
  63042. }
  63043. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  63044. /** @hidden */
  63045. export var lensHighlightsPixelShader: {
  63046. name: string;
  63047. shader: string;
  63048. };
  63049. }
  63050. declare module "babylonjs/Shaders/depthOfField.fragment" {
  63051. /** @hidden */
  63052. export var depthOfFieldPixelShader: {
  63053. name: string;
  63054. shader: string;
  63055. };
  63056. }
  63057. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  63058. import { Camera } from "babylonjs/Cameras/camera";
  63059. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63060. import { Scene } from "babylonjs/scene";
  63061. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63062. import "babylonjs/Shaders/chromaticAberration.fragment";
  63063. import "babylonjs/Shaders/lensHighlights.fragment";
  63064. import "babylonjs/Shaders/depthOfField.fragment";
  63065. /**
  63066. * BABYLON.JS Chromatic Aberration GLSL Shader
  63067. * Author: Olivier Guyot
  63068. * Separates very slightly R, G and B colors on the edges of the screen
  63069. * Inspired by Francois Tarlier & Martins Upitis
  63070. */
  63071. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  63072. /**
  63073. * @ignore
  63074. * The chromatic aberration PostProcess id in the pipeline
  63075. */
  63076. LensChromaticAberrationEffect: string;
  63077. /**
  63078. * @ignore
  63079. * The highlights enhancing PostProcess id in the pipeline
  63080. */
  63081. HighlightsEnhancingEffect: string;
  63082. /**
  63083. * @ignore
  63084. * The depth-of-field PostProcess id in the pipeline
  63085. */
  63086. LensDepthOfFieldEffect: string;
  63087. private _scene;
  63088. private _depthTexture;
  63089. private _grainTexture;
  63090. private _chromaticAberrationPostProcess;
  63091. private _highlightsPostProcess;
  63092. private _depthOfFieldPostProcess;
  63093. private _edgeBlur;
  63094. private _grainAmount;
  63095. private _chromaticAberration;
  63096. private _distortion;
  63097. private _highlightsGain;
  63098. private _highlightsThreshold;
  63099. private _dofDistance;
  63100. private _dofAperture;
  63101. private _dofDarken;
  63102. private _dofPentagon;
  63103. private _blurNoise;
  63104. /**
  63105. * @constructor
  63106. *
  63107. * Effect parameters are as follow:
  63108. * {
  63109. * chromatic_aberration: number; // from 0 to x (1 for realism)
  63110. * edge_blur: number; // from 0 to x (1 for realism)
  63111. * distortion: number; // from 0 to x (1 for realism)
  63112. * grain_amount: number; // from 0 to 1
  63113. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  63114. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  63115. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  63116. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  63117. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  63118. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  63119. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  63120. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  63121. * }
  63122. * Note: if an effect parameter is unset, effect is disabled
  63123. *
  63124. * @param name The rendering pipeline name
  63125. * @param parameters - An object containing all parameters (see above)
  63126. * @param scene The scene linked to this pipeline
  63127. * @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)
  63128. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63129. */
  63130. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  63131. /**
  63132. * Get the class name
  63133. * @returns "LensRenderingPipeline"
  63134. */
  63135. getClassName(): string;
  63136. /**
  63137. * Gets associated scene
  63138. */
  63139. readonly scene: Scene;
  63140. /**
  63141. * Gets or sets the edge blur
  63142. */
  63143. edgeBlur: number;
  63144. /**
  63145. * Gets or sets the grain amount
  63146. */
  63147. grainAmount: number;
  63148. /**
  63149. * Gets or sets the chromatic aberration amount
  63150. */
  63151. chromaticAberration: number;
  63152. /**
  63153. * Gets or sets the depth of field aperture
  63154. */
  63155. dofAperture: number;
  63156. /**
  63157. * Gets or sets the edge distortion
  63158. */
  63159. edgeDistortion: number;
  63160. /**
  63161. * Gets or sets the depth of field distortion
  63162. */
  63163. dofDistortion: number;
  63164. /**
  63165. * Gets or sets the darken out of focus amount
  63166. */
  63167. darkenOutOfFocus: number;
  63168. /**
  63169. * Gets or sets a boolean indicating if blur noise is enabled
  63170. */
  63171. blurNoise: boolean;
  63172. /**
  63173. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63174. */
  63175. pentagonBokeh: boolean;
  63176. /**
  63177. * Gets or sets the highlight grain amount
  63178. */
  63179. highlightsGain: number;
  63180. /**
  63181. * Gets or sets the highlight threshold
  63182. */
  63183. highlightsThreshold: number;
  63184. /**
  63185. * Sets the amount of blur at the edges
  63186. * @param amount blur amount
  63187. */
  63188. setEdgeBlur(amount: number): void;
  63189. /**
  63190. * Sets edge blur to 0
  63191. */
  63192. disableEdgeBlur(): void;
  63193. /**
  63194. * Sets the amout of grain
  63195. * @param amount Amount of grain
  63196. */
  63197. setGrainAmount(amount: number): void;
  63198. /**
  63199. * Set grain amount to 0
  63200. */
  63201. disableGrain(): void;
  63202. /**
  63203. * Sets the chromatic aberration amount
  63204. * @param amount amount of chromatic aberration
  63205. */
  63206. setChromaticAberration(amount: number): void;
  63207. /**
  63208. * Sets chromatic aberration amount to 0
  63209. */
  63210. disableChromaticAberration(): void;
  63211. /**
  63212. * Sets the EdgeDistortion amount
  63213. * @param amount amount of EdgeDistortion
  63214. */
  63215. setEdgeDistortion(amount: number): void;
  63216. /**
  63217. * Sets edge distortion to 0
  63218. */
  63219. disableEdgeDistortion(): void;
  63220. /**
  63221. * Sets the FocusDistance amount
  63222. * @param amount amount of FocusDistance
  63223. */
  63224. setFocusDistance(amount: number): void;
  63225. /**
  63226. * Disables depth of field
  63227. */
  63228. disableDepthOfField(): void;
  63229. /**
  63230. * Sets the Aperture amount
  63231. * @param amount amount of Aperture
  63232. */
  63233. setAperture(amount: number): void;
  63234. /**
  63235. * Sets the DarkenOutOfFocus amount
  63236. * @param amount amount of DarkenOutOfFocus
  63237. */
  63238. setDarkenOutOfFocus(amount: number): void;
  63239. private _pentagonBokehIsEnabled;
  63240. /**
  63241. * Creates a pentagon bokeh effect
  63242. */
  63243. enablePentagonBokeh(): void;
  63244. /**
  63245. * Disables the pentagon bokeh effect
  63246. */
  63247. disablePentagonBokeh(): void;
  63248. /**
  63249. * Enables noise blur
  63250. */
  63251. enableNoiseBlur(): void;
  63252. /**
  63253. * Disables noise blur
  63254. */
  63255. disableNoiseBlur(): void;
  63256. /**
  63257. * Sets the HighlightsGain amount
  63258. * @param amount amount of HighlightsGain
  63259. */
  63260. setHighlightsGain(amount: number): void;
  63261. /**
  63262. * Sets the HighlightsThreshold amount
  63263. * @param amount amount of HighlightsThreshold
  63264. */
  63265. setHighlightsThreshold(amount: number): void;
  63266. /**
  63267. * Disables highlights
  63268. */
  63269. disableHighlights(): void;
  63270. /**
  63271. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63272. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63273. */
  63274. dispose(disableDepthRender?: boolean): void;
  63275. private _createChromaticAberrationPostProcess;
  63276. private _createHighlightsPostProcess;
  63277. private _createDepthOfFieldPostProcess;
  63278. private _createGrainTexture;
  63279. }
  63280. }
  63281. declare module "babylonjs/Shaders/ssao2.fragment" {
  63282. /** @hidden */
  63283. export var ssao2PixelShader: {
  63284. name: string;
  63285. shader: string;
  63286. };
  63287. }
  63288. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  63289. /** @hidden */
  63290. export var ssaoCombinePixelShader: {
  63291. name: string;
  63292. shader: string;
  63293. };
  63294. }
  63295. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  63296. import { Camera } from "babylonjs/Cameras/camera";
  63297. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63298. import { Scene } from "babylonjs/scene";
  63299. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63300. import "babylonjs/Shaders/ssao2.fragment";
  63301. import "babylonjs/Shaders/ssaoCombine.fragment";
  63302. /**
  63303. * Render pipeline to produce ssao effect
  63304. */
  63305. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63306. /**
  63307. * @ignore
  63308. * The PassPostProcess id in the pipeline that contains the original scene color
  63309. */
  63310. SSAOOriginalSceneColorEffect: string;
  63311. /**
  63312. * @ignore
  63313. * The SSAO PostProcess id in the pipeline
  63314. */
  63315. SSAORenderEffect: string;
  63316. /**
  63317. * @ignore
  63318. * The horizontal blur PostProcess id in the pipeline
  63319. */
  63320. SSAOBlurHRenderEffect: string;
  63321. /**
  63322. * @ignore
  63323. * The vertical blur PostProcess id in the pipeline
  63324. */
  63325. SSAOBlurVRenderEffect: string;
  63326. /**
  63327. * @ignore
  63328. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63329. */
  63330. SSAOCombineRenderEffect: string;
  63331. /**
  63332. * The output strength of the SSAO post-process. Default value is 1.0.
  63333. */
  63334. totalStrength: number;
  63335. /**
  63336. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63337. */
  63338. maxZ: number;
  63339. /**
  63340. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63341. */
  63342. minZAspect: number;
  63343. private _samples;
  63344. /**
  63345. * Number of samples used for the SSAO calculations. Default value is 8
  63346. */
  63347. samples: number;
  63348. private _textureSamples;
  63349. /**
  63350. * Number of samples to use for antialiasing
  63351. */
  63352. textureSamples: number;
  63353. /**
  63354. * Ratio object used for SSAO ratio and blur ratio
  63355. */
  63356. private _ratio;
  63357. /**
  63358. * Dynamically generated sphere sampler.
  63359. */
  63360. private _sampleSphere;
  63361. /**
  63362. * Blur filter offsets
  63363. */
  63364. private _samplerOffsets;
  63365. private _expensiveBlur;
  63366. /**
  63367. * If bilateral blur should be used
  63368. */
  63369. expensiveBlur: boolean;
  63370. /**
  63371. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63372. */
  63373. radius: number;
  63374. /**
  63375. * The base color of the SSAO post-process
  63376. * The final result is "base + ssao" between [0, 1]
  63377. */
  63378. base: number;
  63379. /**
  63380. * Support test.
  63381. */
  63382. static readonly IsSupported: boolean;
  63383. private _scene;
  63384. private _depthTexture;
  63385. private _normalTexture;
  63386. private _randomTexture;
  63387. private _originalColorPostProcess;
  63388. private _ssaoPostProcess;
  63389. private _blurHPostProcess;
  63390. private _blurVPostProcess;
  63391. private _ssaoCombinePostProcess;
  63392. private _firstUpdate;
  63393. /**
  63394. * Gets active scene
  63395. */
  63396. readonly scene: Scene;
  63397. /**
  63398. * @constructor
  63399. * @param name The rendering pipeline name
  63400. * @param scene The scene linked to this pipeline
  63401. * @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 }
  63402. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63403. */
  63404. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63405. /**
  63406. * Get the class name
  63407. * @returns "SSAO2RenderingPipeline"
  63408. */
  63409. getClassName(): string;
  63410. /**
  63411. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63412. */
  63413. dispose(disableGeometryBufferRenderer?: boolean): void;
  63414. private _createBlurPostProcess;
  63415. /** @hidden */
  63416. _rebuild(): void;
  63417. private _bits;
  63418. private _radicalInverse_VdC;
  63419. private _hammersley;
  63420. private _hemisphereSample_uniform;
  63421. private _generateHemisphere;
  63422. private _createSSAOPostProcess;
  63423. private _createSSAOCombinePostProcess;
  63424. private _createRandomTexture;
  63425. /**
  63426. * Serialize the rendering pipeline (Used when exporting)
  63427. * @returns the serialized object
  63428. */
  63429. serialize(): any;
  63430. /**
  63431. * Parse the serialized pipeline
  63432. * @param source Source pipeline.
  63433. * @param scene The scene to load the pipeline to.
  63434. * @param rootUrl The URL of the serialized pipeline.
  63435. * @returns An instantiated pipeline from the serialized object.
  63436. */
  63437. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63438. }
  63439. }
  63440. declare module "babylonjs/Shaders/ssao.fragment" {
  63441. /** @hidden */
  63442. export var ssaoPixelShader: {
  63443. name: string;
  63444. shader: string;
  63445. };
  63446. }
  63447. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  63448. import { Camera } from "babylonjs/Cameras/camera";
  63449. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63450. import { Scene } from "babylonjs/scene";
  63451. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63452. import "babylonjs/Shaders/ssao.fragment";
  63453. import "babylonjs/Shaders/ssaoCombine.fragment";
  63454. /**
  63455. * Render pipeline to produce ssao effect
  63456. */
  63457. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63458. /**
  63459. * @ignore
  63460. * The PassPostProcess id in the pipeline that contains the original scene color
  63461. */
  63462. SSAOOriginalSceneColorEffect: string;
  63463. /**
  63464. * @ignore
  63465. * The SSAO PostProcess id in the pipeline
  63466. */
  63467. SSAORenderEffect: string;
  63468. /**
  63469. * @ignore
  63470. * The horizontal blur PostProcess id in the pipeline
  63471. */
  63472. SSAOBlurHRenderEffect: string;
  63473. /**
  63474. * @ignore
  63475. * The vertical blur PostProcess id in the pipeline
  63476. */
  63477. SSAOBlurVRenderEffect: string;
  63478. /**
  63479. * @ignore
  63480. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63481. */
  63482. SSAOCombineRenderEffect: string;
  63483. /**
  63484. * The output strength of the SSAO post-process. Default value is 1.0.
  63485. */
  63486. totalStrength: number;
  63487. /**
  63488. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63489. */
  63490. radius: number;
  63491. /**
  63492. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63493. * Must not be equal to fallOff and superior to fallOff.
  63494. * Default value is 0.0075
  63495. */
  63496. area: number;
  63497. /**
  63498. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63499. * Must not be equal to area and inferior to area.
  63500. * Default value is 0.000001
  63501. */
  63502. fallOff: number;
  63503. /**
  63504. * The base color of the SSAO post-process
  63505. * The final result is "base + ssao" between [0, 1]
  63506. */
  63507. base: number;
  63508. private _scene;
  63509. private _depthTexture;
  63510. private _randomTexture;
  63511. private _originalColorPostProcess;
  63512. private _ssaoPostProcess;
  63513. private _blurHPostProcess;
  63514. private _blurVPostProcess;
  63515. private _ssaoCombinePostProcess;
  63516. private _firstUpdate;
  63517. /**
  63518. * Gets active scene
  63519. */
  63520. readonly scene: Scene;
  63521. /**
  63522. * @constructor
  63523. * @param name - The rendering pipeline name
  63524. * @param scene - The scene linked to this pipeline
  63525. * @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 }
  63526. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63527. */
  63528. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63529. /**
  63530. * Get the class name
  63531. * @returns "SSAORenderingPipeline"
  63532. */
  63533. getClassName(): string;
  63534. /**
  63535. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63536. */
  63537. dispose(disableDepthRender?: boolean): void;
  63538. private _createBlurPostProcess;
  63539. /** @hidden */
  63540. _rebuild(): void;
  63541. private _createSSAOPostProcess;
  63542. private _createSSAOCombinePostProcess;
  63543. private _createRandomTexture;
  63544. }
  63545. }
  63546. declare module "babylonjs/Shaders/standard.fragment" {
  63547. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63548. /** @hidden */
  63549. export var standardPixelShader: {
  63550. name: string;
  63551. shader: string;
  63552. };
  63553. }
  63554. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  63555. import { Nullable } from "babylonjs/types";
  63556. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63557. import { Camera } from "babylonjs/Cameras/camera";
  63558. import { Texture } from "babylonjs/Materials/Textures/texture";
  63559. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63560. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63561. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63562. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63563. import { IDisposable } from "babylonjs/scene";
  63564. import { SpotLight } from "babylonjs/Lights/spotLight";
  63565. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63566. import { Scene } from "babylonjs/scene";
  63567. import { Animation } from "babylonjs/Animations/animation";
  63568. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63569. import "babylonjs/Shaders/standard.fragment";
  63570. /**
  63571. * Standard rendering pipeline
  63572. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63573. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  63574. */
  63575. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63576. /**
  63577. * Public members
  63578. */
  63579. /**
  63580. * Post-process which contains the original scene color before the pipeline applies all the effects
  63581. */
  63582. originalPostProcess: Nullable<PostProcess>;
  63583. /**
  63584. * Post-process used to down scale an image x4
  63585. */
  63586. downSampleX4PostProcess: Nullable<PostProcess>;
  63587. /**
  63588. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  63589. */
  63590. brightPassPostProcess: Nullable<PostProcess>;
  63591. /**
  63592. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  63593. */
  63594. blurHPostProcesses: PostProcess[];
  63595. /**
  63596. * Post-process array storing all the vertical blur post-processes used by the pipeline
  63597. */
  63598. blurVPostProcesses: PostProcess[];
  63599. /**
  63600. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  63601. */
  63602. textureAdderPostProcess: Nullable<PostProcess>;
  63603. /**
  63604. * Post-process used to create volumetric lighting effect
  63605. */
  63606. volumetricLightPostProcess: Nullable<PostProcess>;
  63607. /**
  63608. * Post-process used to smooth the previous volumetric light post-process on the X axis
  63609. */
  63610. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  63611. /**
  63612. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  63613. */
  63614. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  63615. /**
  63616. * Post-process used to merge the volumetric light effect and the real scene color
  63617. */
  63618. volumetricLightMergePostProces: Nullable<PostProcess>;
  63619. /**
  63620. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  63621. */
  63622. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  63623. /**
  63624. * Base post-process used to calculate the average luminance of the final image for HDR
  63625. */
  63626. luminancePostProcess: Nullable<PostProcess>;
  63627. /**
  63628. * Post-processes used to create down sample post-processes in order to get
  63629. * the average luminance of the final image for HDR
  63630. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  63631. */
  63632. luminanceDownSamplePostProcesses: PostProcess[];
  63633. /**
  63634. * Post-process used to create a HDR effect (light adaptation)
  63635. */
  63636. hdrPostProcess: Nullable<PostProcess>;
  63637. /**
  63638. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  63639. */
  63640. textureAdderFinalPostProcess: Nullable<PostProcess>;
  63641. /**
  63642. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  63643. */
  63644. lensFlareFinalPostProcess: Nullable<PostProcess>;
  63645. /**
  63646. * Post-process used to merge the final HDR post-process and the real scene color
  63647. */
  63648. hdrFinalPostProcess: Nullable<PostProcess>;
  63649. /**
  63650. * Post-process used to create a lens flare effect
  63651. */
  63652. lensFlarePostProcess: Nullable<PostProcess>;
  63653. /**
  63654. * Post-process that merges the result of the lens flare post-process and the real scene color
  63655. */
  63656. lensFlareComposePostProcess: Nullable<PostProcess>;
  63657. /**
  63658. * Post-process used to create a motion blur effect
  63659. */
  63660. motionBlurPostProcess: Nullable<PostProcess>;
  63661. /**
  63662. * Post-process used to create a depth of field effect
  63663. */
  63664. depthOfFieldPostProcess: Nullable<PostProcess>;
  63665. /**
  63666. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63667. */
  63668. fxaaPostProcess: Nullable<FxaaPostProcess>;
  63669. /**
  63670. * Represents the brightness threshold in order to configure the illuminated surfaces
  63671. */
  63672. brightThreshold: number;
  63673. /**
  63674. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  63675. */
  63676. blurWidth: number;
  63677. /**
  63678. * Sets if the blur for highlighted surfaces must be only horizontal
  63679. */
  63680. horizontalBlur: boolean;
  63681. /**
  63682. * Gets the overall exposure used by the pipeline
  63683. */
  63684. /**
  63685. * Sets the overall exposure used by the pipeline
  63686. */
  63687. exposure: number;
  63688. /**
  63689. * Texture used typically to simulate "dirty" on camera lens
  63690. */
  63691. lensTexture: Nullable<Texture>;
  63692. /**
  63693. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  63694. */
  63695. volumetricLightCoefficient: number;
  63696. /**
  63697. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  63698. */
  63699. volumetricLightPower: number;
  63700. /**
  63701. * Used the set the blur intensity to smooth the volumetric lights
  63702. */
  63703. volumetricLightBlurScale: number;
  63704. /**
  63705. * Light (spot or directional) used to generate the volumetric lights rays
  63706. * The source light must have a shadow generate so the pipeline can get its
  63707. * depth map
  63708. */
  63709. sourceLight: Nullable<SpotLight | DirectionalLight>;
  63710. /**
  63711. * For eye adaptation, represents the minimum luminance the eye can see
  63712. */
  63713. hdrMinimumLuminance: number;
  63714. /**
  63715. * For eye adaptation, represents the decrease luminance speed
  63716. */
  63717. hdrDecreaseRate: number;
  63718. /**
  63719. * For eye adaptation, represents the increase luminance speed
  63720. */
  63721. hdrIncreaseRate: number;
  63722. /**
  63723. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63724. */
  63725. /**
  63726. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63727. */
  63728. hdrAutoExposure: boolean;
  63729. /**
  63730. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  63731. */
  63732. lensColorTexture: Nullable<Texture>;
  63733. /**
  63734. * The overall strengh for the lens flare effect
  63735. */
  63736. lensFlareStrength: number;
  63737. /**
  63738. * Dispersion coefficient for lens flare ghosts
  63739. */
  63740. lensFlareGhostDispersal: number;
  63741. /**
  63742. * Main lens flare halo width
  63743. */
  63744. lensFlareHaloWidth: number;
  63745. /**
  63746. * Based on the lens distortion effect, defines how much the lens flare result
  63747. * is distorted
  63748. */
  63749. lensFlareDistortionStrength: number;
  63750. /**
  63751. * Configures the blur intensity used for for lens flare (halo)
  63752. */
  63753. lensFlareBlurWidth: number;
  63754. /**
  63755. * Lens star texture must be used to simulate rays on the flares and is available
  63756. * in the documentation
  63757. */
  63758. lensStarTexture: Nullable<Texture>;
  63759. /**
  63760. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  63761. * flare effect by taking account of the dirt texture
  63762. */
  63763. lensFlareDirtTexture: Nullable<Texture>;
  63764. /**
  63765. * Represents the focal length for the depth of field effect
  63766. */
  63767. depthOfFieldDistance: number;
  63768. /**
  63769. * Represents the blur intensity for the blurred part of the depth of field effect
  63770. */
  63771. depthOfFieldBlurWidth: number;
  63772. /**
  63773. * Gets how much the image is blurred by the movement while using the motion blur post-process
  63774. */
  63775. /**
  63776. * Sets how much the image is blurred by the movement while using the motion blur post-process
  63777. */
  63778. motionStrength: number;
  63779. /**
  63780. * Gets wether or not the motion blur post-process is object based or screen based.
  63781. */
  63782. /**
  63783. * Sets wether or not the motion blur post-process should be object based or screen based
  63784. */
  63785. objectBasedMotionBlur: boolean;
  63786. /**
  63787. * List of animations for the pipeline (IAnimatable implementation)
  63788. */
  63789. animations: Animation[];
  63790. /**
  63791. * Private members
  63792. */
  63793. private _scene;
  63794. private _currentDepthOfFieldSource;
  63795. private _basePostProcess;
  63796. private _fixedExposure;
  63797. private _currentExposure;
  63798. private _hdrAutoExposure;
  63799. private _hdrCurrentLuminance;
  63800. private _motionStrength;
  63801. private _isObjectBasedMotionBlur;
  63802. private _floatTextureType;
  63803. private _camerasToBeAttached;
  63804. private _ratio;
  63805. private _bloomEnabled;
  63806. private _depthOfFieldEnabled;
  63807. private _vlsEnabled;
  63808. private _lensFlareEnabled;
  63809. private _hdrEnabled;
  63810. private _motionBlurEnabled;
  63811. private _fxaaEnabled;
  63812. private _motionBlurSamples;
  63813. private _volumetricLightStepsCount;
  63814. private _samples;
  63815. /**
  63816. * @ignore
  63817. * Specifies if the bloom pipeline is enabled
  63818. */
  63819. BloomEnabled: boolean;
  63820. /**
  63821. * @ignore
  63822. * Specifies if the depth of field pipeline is enabed
  63823. */
  63824. DepthOfFieldEnabled: boolean;
  63825. /**
  63826. * @ignore
  63827. * Specifies if the lens flare pipeline is enabed
  63828. */
  63829. LensFlareEnabled: boolean;
  63830. /**
  63831. * @ignore
  63832. * Specifies if the HDR pipeline is enabled
  63833. */
  63834. HDREnabled: boolean;
  63835. /**
  63836. * @ignore
  63837. * Specifies if the volumetric lights scattering effect is enabled
  63838. */
  63839. VLSEnabled: boolean;
  63840. /**
  63841. * @ignore
  63842. * Specifies if the motion blur effect is enabled
  63843. */
  63844. MotionBlurEnabled: boolean;
  63845. /**
  63846. * Specifies if anti-aliasing is enabled
  63847. */
  63848. fxaaEnabled: boolean;
  63849. /**
  63850. * Specifies the number of steps used to calculate the volumetric lights
  63851. * Typically in interval [50, 200]
  63852. */
  63853. volumetricLightStepsCount: number;
  63854. /**
  63855. * Specifies the number of samples used for the motion blur effect
  63856. * Typically in interval [16, 64]
  63857. */
  63858. motionBlurSamples: number;
  63859. /**
  63860. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63861. */
  63862. samples: number;
  63863. /**
  63864. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63865. * @constructor
  63866. * @param name The rendering pipeline name
  63867. * @param scene The scene linked to this pipeline
  63868. * @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)
  63869. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  63870. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63871. */
  63872. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  63873. private _buildPipeline;
  63874. private _createDownSampleX4PostProcess;
  63875. private _createBrightPassPostProcess;
  63876. private _createBlurPostProcesses;
  63877. private _createTextureAdderPostProcess;
  63878. private _createVolumetricLightPostProcess;
  63879. private _createLuminancePostProcesses;
  63880. private _createHdrPostProcess;
  63881. private _createLensFlarePostProcess;
  63882. private _createDepthOfFieldPostProcess;
  63883. private _createMotionBlurPostProcess;
  63884. private _getDepthTexture;
  63885. private _disposePostProcesses;
  63886. /**
  63887. * Dispose of the pipeline and stop all post processes
  63888. */
  63889. dispose(): void;
  63890. /**
  63891. * Serialize the rendering pipeline (Used when exporting)
  63892. * @returns the serialized object
  63893. */
  63894. serialize(): any;
  63895. /**
  63896. * Parse the serialized pipeline
  63897. * @param source Source pipeline.
  63898. * @param scene The scene to load the pipeline to.
  63899. * @param rootUrl The URL of the serialized pipeline.
  63900. * @returns An instantiated pipeline from the serialized object.
  63901. */
  63902. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  63903. /**
  63904. * Luminance steps
  63905. */
  63906. static LuminanceSteps: number;
  63907. }
  63908. }
  63909. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  63910. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  63911. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  63912. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  63913. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  63914. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  63915. }
  63916. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  63917. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  63918. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63919. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63920. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63921. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63922. }
  63923. declare module "babylonjs/Shaders/tonemap.fragment" {
  63924. /** @hidden */
  63925. export var tonemapPixelShader: {
  63926. name: string;
  63927. shader: string;
  63928. };
  63929. }
  63930. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  63931. import { Camera } from "babylonjs/Cameras/camera";
  63932. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63933. import "babylonjs/Shaders/tonemap.fragment";
  63934. import { Engine } from "babylonjs/Engines/engine";
  63935. /** Defines operator used for tonemapping */
  63936. export enum TonemappingOperator {
  63937. /** Hable */
  63938. Hable = 0,
  63939. /** Reinhard */
  63940. Reinhard = 1,
  63941. /** HejiDawson */
  63942. HejiDawson = 2,
  63943. /** Photographic */
  63944. Photographic = 3
  63945. }
  63946. /**
  63947. * Defines a post process to apply tone mapping
  63948. */
  63949. export class TonemapPostProcess extends PostProcess {
  63950. private _operator;
  63951. /** Defines the required exposure adjustement */
  63952. exposureAdjustment: number;
  63953. /**
  63954. * Creates a new TonemapPostProcess
  63955. * @param name defines the name of the postprocess
  63956. * @param _operator defines the operator to use
  63957. * @param exposureAdjustment defines the required exposure adjustement
  63958. * @param camera defines the camera to use (can be null)
  63959. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  63960. * @param engine defines the hosting engine (can be ignore if camera is set)
  63961. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63962. */
  63963. constructor(name: string, _operator: TonemappingOperator,
  63964. /** Defines the required exposure adjustement */
  63965. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  63966. }
  63967. }
  63968. declare module "babylonjs/Shaders/depth.vertex" {
  63969. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63970. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63971. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63972. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63973. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63974. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63975. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63976. /** @hidden */
  63977. export var depthVertexShader: {
  63978. name: string;
  63979. shader: string;
  63980. };
  63981. }
  63982. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  63983. /** @hidden */
  63984. export var volumetricLightScatteringPixelShader: {
  63985. name: string;
  63986. shader: string;
  63987. };
  63988. }
  63989. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  63990. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63991. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63992. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63993. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63994. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63995. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63996. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63997. /** @hidden */
  63998. export var volumetricLightScatteringPassVertexShader: {
  63999. name: string;
  64000. shader: string;
  64001. };
  64002. }
  64003. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  64004. /** @hidden */
  64005. export var volumetricLightScatteringPassPixelShader: {
  64006. name: string;
  64007. shader: string;
  64008. };
  64009. }
  64010. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  64011. import { Vector3 } from "babylonjs/Maths/math.vector";
  64012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64013. import { Mesh } from "babylonjs/Meshes/mesh";
  64014. import { Camera } from "babylonjs/Cameras/camera";
  64015. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64016. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64017. import { Scene } from "babylonjs/scene";
  64018. import "babylonjs/Meshes/Builders/planeBuilder";
  64019. import "babylonjs/Shaders/depth.vertex";
  64020. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  64021. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  64022. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  64023. import { Engine } from "babylonjs/Engines/engine";
  64024. /**
  64025. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  64026. */
  64027. export class VolumetricLightScatteringPostProcess extends PostProcess {
  64028. private _volumetricLightScatteringPass;
  64029. private _volumetricLightScatteringRTT;
  64030. private _viewPort;
  64031. private _screenCoordinates;
  64032. private _cachedDefines;
  64033. /**
  64034. * If not undefined, the mesh position is computed from the attached node position
  64035. */
  64036. attachedNode: {
  64037. position: Vector3;
  64038. };
  64039. /**
  64040. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  64041. */
  64042. customMeshPosition: Vector3;
  64043. /**
  64044. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  64045. */
  64046. useCustomMeshPosition: boolean;
  64047. /**
  64048. * If the post-process should inverse the light scattering direction
  64049. */
  64050. invert: boolean;
  64051. /**
  64052. * The internal mesh used by the post-process
  64053. */
  64054. mesh: Mesh;
  64055. /**
  64056. * @hidden
  64057. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  64058. */
  64059. useDiffuseColor: boolean;
  64060. /**
  64061. * Array containing the excluded meshes not rendered in the internal pass
  64062. */
  64063. excludedMeshes: AbstractMesh[];
  64064. /**
  64065. * Controls the overall intensity of the post-process
  64066. */
  64067. exposure: number;
  64068. /**
  64069. * Dissipates each sample's contribution in range [0, 1]
  64070. */
  64071. decay: number;
  64072. /**
  64073. * Controls the overall intensity of each sample
  64074. */
  64075. weight: number;
  64076. /**
  64077. * Controls the density of each sample
  64078. */
  64079. density: number;
  64080. /**
  64081. * @constructor
  64082. * @param name The post-process name
  64083. * @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)
  64084. * @param camera The camera that the post-process will be attached to
  64085. * @param mesh The mesh used to create the light scattering
  64086. * @param samples The post-process quality, default 100
  64087. * @param samplingModeThe post-process filtering mode
  64088. * @param engine The babylon engine
  64089. * @param reusable If the post-process is reusable
  64090. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  64091. */
  64092. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  64093. /**
  64094. * Returns the string "VolumetricLightScatteringPostProcess"
  64095. * @returns "VolumetricLightScatteringPostProcess"
  64096. */
  64097. getClassName(): string;
  64098. private _isReady;
  64099. /**
  64100. * Sets the new light position for light scattering effect
  64101. * @param position The new custom light position
  64102. */
  64103. setCustomMeshPosition(position: Vector3): void;
  64104. /**
  64105. * Returns the light position for light scattering effect
  64106. * @return Vector3 The custom light position
  64107. */
  64108. getCustomMeshPosition(): Vector3;
  64109. /**
  64110. * Disposes the internal assets and detaches the post-process from the camera
  64111. */
  64112. dispose(camera: Camera): void;
  64113. /**
  64114. * Returns the render target texture used by the post-process
  64115. * @return the render target texture used by the post-process
  64116. */
  64117. getPass(): RenderTargetTexture;
  64118. private _meshExcluded;
  64119. private _createPass;
  64120. private _updateMeshScreenCoordinates;
  64121. /**
  64122. * Creates a default mesh for the Volumeric Light Scattering post-process
  64123. * @param name The mesh name
  64124. * @param scene The scene where to create the mesh
  64125. * @return the default mesh
  64126. */
  64127. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  64128. }
  64129. }
  64130. declare module "babylonjs/PostProcesses/index" {
  64131. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  64132. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  64133. export * from "babylonjs/PostProcesses/bloomEffect";
  64134. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  64135. export * from "babylonjs/PostProcesses/blurPostProcess";
  64136. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64137. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  64138. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  64139. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  64140. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64141. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  64142. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  64143. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  64144. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64145. export * from "babylonjs/PostProcesses/filterPostProcess";
  64146. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  64147. export * from "babylonjs/PostProcesses/grainPostProcess";
  64148. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  64149. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64150. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  64151. export * from "babylonjs/PostProcesses/passPostProcess";
  64152. export * from "babylonjs/PostProcesses/postProcess";
  64153. export * from "babylonjs/PostProcesses/postProcessManager";
  64154. export * from "babylonjs/PostProcesses/refractionPostProcess";
  64155. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  64156. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  64157. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  64158. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  64159. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  64160. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  64161. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  64162. }
  64163. declare module "babylonjs/Probes/index" {
  64164. export * from "babylonjs/Probes/reflectionProbe";
  64165. }
  64166. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  64167. import { Scene } from "babylonjs/scene";
  64168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64169. import { SmartArray } from "babylonjs/Misc/smartArray";
  64170. import { ISceneComponent } from "babylonjs/sceneComponent";
  64171. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  64172. import "babylonjs/Meshes/Builders/boxBuilder";
  64173. import "babylonjs/Shaders/color.fragment";
  64174. import "babylonjs/Shaders/color.vertex";
  64175. import { Color3 } from "babylonjs/Maths/math.color";
  64176. module "babylonjs/scene" {
  64177. interface Scene {
  64178. /** @hidden (Backing field) */
  64179. _boundingBoxRenderer: BoundingBoxRenderer;
  64180. /** @hidden (Backing field) */
  64181. _forceShowBoundingBoxes: boolean;
  64182. /**
  64183. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  64184. */
  64185. forceShowBoundingBoxes: boolean;
  64186. /**
  64187. * Gets the bounding box renderer associated with the scene
  64188. * @returns a BoundingBoxRenderer
  64189. */
  64190. getBoundingBoxRenderer(): BoundingBoxRenderer;
  64191. }
  64192. }
  64193. module "babylonjs/Meshes/abstractMesh" {
  64194. interface AbstractMesh {
  64195. /** @hidden (Backing field) */
  64196. _showBoundingBox: boolean;
  64197. /**
  64198. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  64199. */
  64200. showBoundingBox: boolean;
  64201. }
  64202. }
  64203. /**
  64204. * Component responsible of rendering the bounding box of the meshes in a scene.
  64205. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  64206. */
  64207. export class BoundingBoxRenderer implements ISceneComponent {
  64208. /**
  64209. * The component name helpfull to identify the component in the list of scene components.
  64210. */
  64211. readonly name: string;
  64212. /**
  64213. * The scene the component belongs to.
  64214. */
  64215. scene: Scene;
  64216. /**
  64217. * Color of the bounding box lines placed in front of an object
  64218. */
  64219. frontColor: Color3;
  64220. /**
  64221. * Color of the bounding box lines placed behind an object
  64222. */
  64223. backColor: Color3;
  64224. /**
  64225. * Defines if the renderer should show the back lines or not
  64226. */
  64227. showBackLines: boolean;
  64228. /**
  64229. * @hidden
  64230. */
  64231. renderList: SmartArray<BoundingBox>;
  64232. private _colorShader;
  64233. private _vertexBuffers;
  64234. private _indexBuffer;
  64235. private _fillIndexBuffer;
  64236. private _fillIndexData;
  64237. /**
  64238. * Instantiates a new bounding box renderer in a scene.
  64239. * @param scene the scene the renderer renders in
  64240. */
  64241. constructor(scene: Scene);
  64242. /**
  64243. * Registers the component in a given scene
  64244. */
  64245. register(): void;
  64246. private _evaluateSubMesh;
  64247. private _activeMesh;
  64248. private _prepareRessources;
  64249. private _createIndexBuffer;
  64250. /**
  64251. * Rebuilds the elements related to this component in case of
  64252. * context lost for instance.
  64253. */
  64254. rebuild(): void;
  64255. /**
  64256. * @hidden
  64257. */
  64258. reset(): void;
  64259. /**
  64260. * Render the bounding boxes of a specific rendering group
  64261. * @param renderingGroupId defines the rendering group to render
  64262. */
  64263. render(renderingGroupId: number): void;
  64264. /**
  64265. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64266. * @param mesh Define the mesh to render the occlusion bounding box for
  64267. */
  64268. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64269. /**
  64270. * Dispose and release the resources attached to this renderer.
  64271. */
  64272. dispose(): void;
  64273. }
  64274. }
  64275. declare module "babylonjs/Shaders/depth.fragment" {
  64276. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64277. /** @hidden */
  64278. export var depthPixelShader: {
  64279. name: string;
  64280. shader: string;
  64281. };
  64282. }
  64283. declare module "babylonjs/Rendering/depthRenderer" {
  64284. import { Nullable } from "babylonjs/types";
  64285. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64286. import { Scene } from "babylonjs/scene";
  64287. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64288. import { Camera } from "babylonjs/Cameras/camera";
  64289. import "babylonjs/Shaders/depth.fragment";
  64290. import "babylonjs/Shaders/depth.vertex";
  64291. /**
  64292. * This represents a depth renderer in Babylon.
  64293. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64294. */
  64295. export class DepthRenderer {
  64296. private _scene;
  64297. private _depthMap;
  64298. private _effect;
  64299. private readonly _storeNonLinearDepth;
  64300. private readonly _clearColor;
  64301. /** Get if the depth renderer is using packed depth or not */
  64302. readonly isPacked: boolean;
  64303. private _cachedDefines;
  64304. private _camera;
  64305. /**
  64306. * Specifiess that the depth renderer will only be used within
  64307. * the camera it is created for.
  64308. * This can help forcing its rendering during the camera processing.
  64309. */
  64310. useOnlyInActiveCamera: boolean;
  64311. /** @hidden */
  64312. static _SceneComponentInitialization: (scene: Scene) => void;
  64313. /**
  64314. * Instantiates a depth renderer
  64315. * @param scene The scene the renderer belongs to
  64316. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64317. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64318. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64319. */
  64320. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64321. /**
  64322. * Creates the depth rendering effect and checks if the effect is ready.
  64323. * @param subMesh The submesh to be used to render the depth map of
  64324. * @param useInstances If multiple world instances should be used
  64325. * @returns if the depth renderer is ready to render the depth map
  64326. */
  64327. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64328. /**
  64329. * Gets the texture which the depth map will be written to.
  64330. * @returns The depth map texture
  64331. */
  64332. getDepthMap(): RenderTargetTexture;
  64333. /**
  64334. * Disposes of the depth renderer.
  64335. */
  64336. dispose(): void;
  64337. }
  64338. }
  64339. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  64340. import { Nullable } from "babylonjs/types";
  64341. import { Scene } from "babylonjs/scene";
  64342. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64343. import { Camera } from "babylonjs/Cameras/camera";
  64344. import { ISceneComponent } from "babylonjs/sceneComponent";
  64345. module "babylonjs/scene" {
  64346. interface Scene {
  64347. /** @hidden (Backing field) */
  64348. _depthRenderer: {
  64349. [id: string]: DepthRenderer;
  64350. };
  64351. /**
  64352. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64353. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64354. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64355. * @returns the created depth renderer
  64356. */
  64357. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64358. /**
  64359. * Disables a depth renderer for a given camera
  64360. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64361. */
  64362. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64363. }
  64364. }
  64365. /**
  64366. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64367. * in several rendering techniques.
  64368. */
  64369. export class DepthRendererSceneComponent implements ISceneComponent {
  64370. /**
  64371. * The component name helpfull to identify the component in the list of scene components.
  64372. */
  64373. readonly name: string;
  64374. /**
  64375. * The scene the component belongs to.
  64376. */
  64377. scene: Scene;
  64378. /**
  64379. * Creates a new instance of the component for the given scene
  64380. * @param scene Defines the scene to register the component in
  64381. */
  64382. constructor(scene: Scene);
  64383. /**
  64384. * Registers the component in a given scene
  64385. */
  64386. register(): void;
  64387. /**
  64388. * Rebuilds the elements related to this component in case of
  64389. * context lost for instance.
  64390. */
  64391. rebuild(): void;
  64392. /**
  64393. * Disposes the component and the associated ressources
  64394. */
  64395. dispose(): void;
  64396. private _gatherRenderTargets;
  64397. private _gatherActiveCameraRenderTargets;
  64398. }
  64399. }
  64400. declare module "babylonjs/Shaders/outline.fragment" {
  64401. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64402. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  64403. /** @hidden */
  64404. export var outlinePixelShader: {
  64405. name: string;
  64406. shader: string;
  64407. };
  64408. }
  64409. declare module "babylonjs/Shaders/outline.vertex" {
  64410. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64411. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64412. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64413. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64414. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64415. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64416. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64417. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64418. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  64419. /** @hidden */
  64420. export var outlineVertexShader: {
  64421. name: string;
  64422. shader: string;
  64423. };
  64424. }
  64425. declare module "babylonjs/Rendering/outlineRenderer" {
  64426. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64427. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  64428. import { Scene } from "babylonjs/scene";
  64429. import { ISceneComponent } from "babylonjs/sceneComponent";
  64430. import "babylonjs/Shaders/outline.fragment";
  64431. import "babylonjs/Shaders/outline.vertex";
  64432. module "babylonjs/scene" {
  64433. interface Scene {
  64434. /** @hidden */
  64435. _outlineRenderer: OutlineRenderer;
  64436. /**
  64437. * Gets the outline renderer associated with the scene
  64438. * @returns a OutlineRenderer
  64439. */
  64440. getOutlineRenderer(): OutlineRenderer;
  64441. }
  64442. }
  64443. module "babylonjs/Meshes/abstractMesh" {
  64444. interface AbstractMesh {
  64445. /** @hidden (Backing field) */
  64446. _renderOutline: boolean;
  64447. /**
  64448. * Gets or sets a boolean indicating if the outline must be rendered as well
  64449. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64450. */
  64451. renderOutline: boolean;
  64452. /** @hidden (Backing field) */
  64453. _renderOverlay: boolean;
  64454. /**
  64455. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64456. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64457. */
  64458. renderOverlay: boolean;
  64459. }
  64460. }
  64461. /**
  64462. * This class is responsible to draw bothe outline/overlay of meshes.
  64463. * It should not be used directly but through the available method on mesh.
  64464. */
  64465. export class OutlineRenderer implements ISceneComponent {
  64466. /**
  64467. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64468. */
  64469. private static _StencilReference;
  64470. /**
  64471. * The name of the component. Each component must have a unique name.
  64472. */
  64473. name: string;
  64474. /**
  64475. * The scene the component belongs to.
  64476. */
  64477. scene: Scene;
  64478. /**
  64479. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64480. */
  64481. zOffset: number;
  64482. private _engine;
  64483. private _effect;
  64484. private _cachedDefines;
  64485. private _savedDepthWrite;
  64486. /**
  64487. * Instantiates a new outline renderer. (There could be only one per scene).
  64488. * @param scene Defines the scene it belongs to
  64489. */
  64490. constructor(scene: Scene);
  64491. /**
  64492. * Register the component to one instance of a scene.
  64493. */
  64494. register(): void;
  64495. /**
  64496. * Rebuilds the elements related to this component in case of
  64497. * context lost for instance.
  64498. */
  64499. rebuild(): void;
  64500. /**
  64501. * Disposes the component and the associated ressources.
  64502. */
  64503. dispose(): void;
  64504. /**
  64505. * Renders the outline in the canvas.
  64506. * @param subMesh Defines the sumesh to render
  64507. * @param batch Defines the batch of meshes in case of instances
  64508. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64509. */
  64510. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64511. /**
  64512. * Returns whether or not the outline renderer is ready for a given submesh.
  64513. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64514. * @param subMesh Defines the submesh to check readyness for
  64515. * @param useInstances Defines wheter wee are trying to render instances or not
  64516. * @returns true if ready otherwise false
  64517. */
  64518. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64519. private _beforeRenderingMesh;
  64520. private _afterRenderingMesh;
  64521. }
  64522. }
  64523. declare module "babylonjs/Rendering/index" {
  64524. export * from "babylonjs/Rendering/boundingBoxRenderer";
  64525. export * from "babylonjs/Rendering/depthRenderer";
  64526. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  64527. export * from "babylonjs/Rendering/edgesRenderer";
  64528. export * from "babylonjs/Rendering/geometryBufferRenderer";
  64529. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64530. export * from "babylonjs/Rendering/outlineRenderer";
  64531. export * from "babylonjs/Rendering/renderingGroup";
  64532. export * from "babylonjs/Rendering/renderingManager";
  64533. export * from "babylonjs/Rendering/utilityLayerRenderer";
  64534. }
  64535. declare module "babylonjs/Sprites/spritePackedManager" {
  64536. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  64537. import { Scene } from "babylonjs/scene";
  64538. /**
  64539. * Class used to manage multiple sprites of different sizes on the same spritesheet
  64540. * @see http://doc.babylonjs.com/babylon101/sprites
  64541. */
  64542. export class SpritePackedManager extends SpriteManager {
  64543. /** defines the packed manager's name */
  64544. name: string;
  64545. /**
  64546. * Creates a new sprite manager from a packed sprite sheet
  64547. * @param name defines the manager's name
  64548. * @param imgUrl defines the sprite sheet url
  64549. * @param capacity defines the maximum allowed number of sprites
  64550. * @param scene defines the hosting scene
  64551. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  64552. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  64553. * @param samplingMode defines the smapling mode to use with spritesheet
  64554. * @param fromPacked set to true; do not alter
  64555. */
  64556. constructor(
  64557. /** defines the packed manager's name */
  64558. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  64559. }
  64560. }
  64561. declare module "babylonjs/Sprites/index" {
  64562. export * from "babylonjs/Sprites/sprite";
  64563. export * from "babylonjs/Sprites/spriteManager";
  64564. export * from "babylonjs/Sprites/spritePackedManager";
  64565. export * from "babylonjs/Sprites/spriteSceneComponent";
  64566. }
  64567. declare module "babylonjs/States/index" {
  64568. export * from "babylonjs/States/alphaCullingState";
  64569. export * from "babylonjs/States/depthCullingState";
  64570. export * from "babylonjs/States/stencilState";
  64571. }
  64572. declare module "babylonjs/Misc/assetsManager" {
  64573. import { Scene } from "babylonjs/scene";
  64574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64575. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64576. import { Skeleton } from "babylonjs/Bones/skeleton";
  64577. import { Observable } from "babylonjs/Misc/observable";
  64578. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64579. import { Texture } from "babylonjs/Materials/Textures/texture";
  64580. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64581. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  64582. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64583. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  64584. /**
  64585. * Defines the list of states available for a task inside a AssetsManager
  64586. */
  64587. export enum AssetTaskState {
  64588. /**
  64589. * Initialization
  64590. */
  64591. INIT = 0,
  64592. /**
  64593. * Running
  64594. */
  64595. RUNNING = 1,
  64596. /**
  64597. * Done
  64598. */
  64599. DONE = 2,
  64600. /**
  64601. * Error
  64602. */
  64603. ERROR = 3
  64604. }
  64605. /**
  64606. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  64607. */
  64608. export abstract class AbstractAssetTask {
  64609. /**
  64610. * Task name
  64611. */ name: string;
  64612. /**
  64613. * Callback called when the task is successful
  64614. */
  64615. onSuccess: (task: any) => void;
  64616. /**
  64617. * Callback called when the task is not successful
  64618. */
  64619. onError: (task: any, message?: string, exception?: any) => void;
  64620. /**
  64621. * Creates a new AssetsManager
  64622. * @param name defines the name of the task
  64623. */
  64624. constructor(
  64625. /**
  64626. * Task name
  64627. */ name: string);
  64628. private _isCompleted;
  64629. private _taskState;
  64630. private _errorObject;
  64631. /**
  64632. * Get if the task is completed
  64633. */
  64634. readonly isCompleted: boolean;
  64635. /**
  64636. * Gets the current state of the task
  64637. */
  64638. readonly taskState: AssetTaskState;
  64639. /**
  64640. * Gets the current error object (if task is in error)
  64641. */
  64642. readonly errorObject: {
  64643. message?: string;
  64644. exception?: any;
  64645. };
  64646. /**
  64647. * Internal only
  64648. * @hidden
  64649. */
  64650. _setErrorObject(message?: string, exception?: any): void;
  64651. /**
  64652. * Execute the current task
  64653. * @param scene defines the scene where you want your assets to be loaded
  64654. * @param onSuccess is a callback called when the task is successfully executed
  64655. * @param onError is a callback called if an error occurs
  64656. */
  64657. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64658. /**
  64659. * Execute the current task
  64660. * @param scene defines the scene where you want your assets to be loaded
  64661. * @param onSuccess is a callback called when the task is successfully executed
  64662. * @param onError is a callback called if an error occurs
  64663. */
  64664. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64665. /**
  64666. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  64667. * This can be used with failed tasks that have the reason for failure fixed.
  64668. */
  64669. reset(): void;
  64670. private onErrorCallback;
  64671. private onDoneCallback;
  64672. }
  64673. /**
  64674. * Define the interface used by progress events raised during assets loading
  64675. */
  64676. export interface IAssetsProgressEvent {
  64677. /**
  64678. * Defines the number of remaining tasks to process
  64679. */
  64680. remainingCount: number;
  64681. /**
  64682. * Defines the total number of tasks
  64683. */
  64684. totalCount: number;
  64685. /**
  64686. * Defines the task that was just processed
  64687. */
  64688. task: AbstractAssetTask;
  64689. }
  64690. /**
  64691. * Class used to share progress information about assets loading
  64692. */
  64693. export class AssetsProgressEvent implements IAssetsProgressEvent {
  64694. /**
  64695. * Defines the number of remaining tasks to process
  64696. */
  64697. remainingCount: number;
  64698. /**
  64699. * Defines the total number of tasks
  64700. */
  64701. totalCount: number;
  64702. /**
  64703. * Defines the task that was just processed
  64704. */
  64705. task: AbstractAssetTask;
  64706. /**
  64707. * Creates a AssetsProgressEvent
  64708. * @param remainingCount defines the number of remaining tasks to process
  64709. * @param totalCount defines the total number of tasks
  64710. * @param task defines the task that was just processed
  64711. */
  64712. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  64713. }
  64714. /**
  64715. * Define a task used by AssetsManager to load meshes
  64716. */
  64717. export class MeshAssetTask extends AbstractAssetTask {
  64718. /**
  64719. * Defines the name of the task
  64720. */
  64721. name: string;
  64722. /**
  64723. * Defines the list of mesh's names you want to load
  64724. */
  64725. meshesNames: any;
  64726. /**
  64727. * Defines the root url to use as a base to load your meshes and associated resources
  64728. */
  64729. rootUrl: string;
  64730. /**
  64731. * Defines the filename of the scene to load from
  64732. */
  64733. sceneFilename: string;
  64734. /**
  64735. * Gets the list of loaded meshes
  64736. */
  64737. loadedMeshes: Array<AbstractMesh>;
  64738. /**
  64739. * Gets the list of loaded particle systems
  64740. */
  64741. loadedParticleSystems: Array<IParticleSystem>;
  64742. /**
  64743. * Gets the list of loaded skeletons
  64744. */
  64745. loadedSkeletons: Array<Skeleton>;
  64746. /**
  64747. * Gets the list of loaded animation groups
  64748. */
  64749. loadedAnimationGroups: Array<AnimationGroup>;
  64750. /**
  64751. * Callback called when the task is successful
  64752. */
  64753. onSuccess: (task: MeshAssetTask) => void;
  64754. /**
  64755. * Callback called when the task is successful
  64756. */
  64757. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  64758. /**
  64759. * Creates a new MeshAssetTask
  64760. * @param name defines the name of the task
  64761. * @param meshesNames defines the list of mesh's names you want to load
  64762. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  64763. * @param sceneFilename defines the filename of the scene to load from
  64764. */
  64765. constructor(
  64766. /**
  64767. * Defines the name of the task
  64768. */
  64769. name: string,
  64770. /**
  64771. * Defines the list of mesh's names you want to load
  64772. */
  64773. meshesNames: any,
  64774. /**
  64775. * Defines the root url to use as a base to load your meshes and associated resources
  64776. */
  64777. rootUrl: string,
  64778. /**
  64779. * Defines the filename of the scene to load from
  64780. */
  64781. sceneFilename: string);
  64782. /**
  64783. * Execute the current task
  64784. * @param scene defines the scene where you want your assets to be loaded
  64785. * @param onSuccess is a callback called when the task is successfully executed
  64786. * @param onError is a callback called if an error occurs
  64787. */
  64788. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64789. }
  64790. /**
  64791. * Define a task used by AssetsManager to load text content
  64792. */
  64793. export class TextFileAssetTask extends AbstractAssetTask {
  64794. /**
  64795. * Defines the name of the task
  64796. */
  64797. name: string;
  64798. /**
  64799. * Defines the location of the file to load
  64800. */
  64801. url: string;
  64802. /**
  64803. * Gets the loaded text string
  64804. */
  64805. text: string;
  64806. /**
  64807. * Callback called when the task is successful
  64808. */
  64809. onSuccess: (task: TextFileAssetTask) => void;
  64810. /**
  64811. * Callback called when the task is successful
  64812. */
  64813. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  64814. /**
  64815. * Creates a new TextFileAssetTask object
  64816. * @param name defines the name of the task
  64817. * @param url defines the location of the file to load
  64818. */
  64819. constructor(
  64820. /**
  64821. * Defines the name of the task
  64822. */
  64823. name: string,
  64824. /**
  64825. * Defines the location of the file to load
  64826. */
  64827. url: string);
  64828. /**
  64829. * Execute the current task
  64830. * @param scene defines the scene where you want your assets to be loaded
  64831. * @param onSuccess is a callback called when the task is successfully executed
  64832. * @param onError is a callback called if an error occurs
  64833. */
  64834. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64835. }
  64836. /**
  64837. * Define a task used by AssetsManager to load binary data
  64838. */
  64839. export class BinaryFileAssetTask extends AbstractAssetTask {
  64840. /**
  64841. * Defines the name of the task
  64842. */
  64843. name: string;
  64844. /**
  64845. * Defines the location of the file to load
  64846. */
  64847. url: string;
  64848. /**
  64849. * Gets the lodaded data (as an array buffer)
  64850. */
  64851. data: ArrayBuffer;
  64852. /**
  64853. * Callback called when the task is successful
  64854. */
  64855. onSuccess: (task: BinaryFileAssetTask) => void;
  64856. /**
  64857. * Callback called when the task is successful
  64858. */
  64859. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  64860. /**
  64861. * Creates a new BinaryFileAssetTask object
  64862. * @param name defines the name of the new task
  64863. * @param url defines the location of the file to load
  64864. */
  64865. constructor(
  64866. /**
  64867. * Defines the name of the task
  64868. */
  64869. name: string,
  64870. /**
  64871. * Defines the location of the file to load
  64872. */
  64873. url: string);
  64874. /**
  64875. * Execute the current task
  64876. * @param scene defines the scene where you want your assets to be loaded
  64877. * @param onSuccess is a callback called when the task is successfully executed
  64878. * @param onError is a callback called if an error occurs
  64879. */
  64880. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64881. }
  64882. /**
  64883. * Define a task used by AssetsManager to load images
  64884. */
  64885. export class ImageAssetTask extends AbstractAssetTask {
  64886. /**
  64887. * Defines the name of the task
  64888. */
  64889. name: string;
  64890. /**
  64891. * Defines the location of the image to load
  64892. */
  64893. url: string;
  64894. /**
  64895. * Gets the loaded images
  64896. */
  64897. image: HTMLImageElement;
  64898. /**
  64899. * Callback called when the task is successful
  64900. */
  64901. onSuccess: (task: ImageAssetTask) => void;
  64902. /**
  64903. * Callback called when the task is successful
  64904. */
  64905. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  64906. /**
  64907. * Creates a new ImageAssetTask
  64908. * @param name defines the name of the task
  64909. * @param url defines the location of the image to load
  64910. */
  64911. constructor(
  64912. /**
  64913. * Defines the name of the task
  64914. */
  64915. name: string,
  64916. /**
  64917. * Defines the location of the image to load
  64918. */
  64919. url: string);
  64920. /**
  64921. * Execute the current task
  64922. * @param scene defines the scene where you want your assets to be loaded
  64923. * @param onSuccess is a callback called when the task is successfully executed
  64924. * @param onError is a callback called if an error occurs
  64925. */
  64926. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64927. }
  64928. /**
  64929. * Defines the interface used by texture loading tasks
  64930. */
  64931. export interface ITextureAssetTask<TEX extends BaseTexture> {
  64932. /**
  64933. * Gets the loaded texture
  64934. */
  64935. texture: TEX;
  64936. }
  64937. /**
  64938. * Define a task used by AssetsManager to load 2D textures
  64939. */
  64940. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  64941. /**
  64942. * Defines the name of the task
  64943. */
  64944. name: string;
  64945. /**
  64946. * Defines the location of the file to load
  64947. */
  64948. url: string;
  64949. /**
  64950. * Defines if mipmap should not be generated (default is false)
  64951. */
  64952. noMipmap?: boolean | undefined;
  64953. /**
  64954. * Defines if texture must be inverted on Y axis (default is false)
  64955. */
  64956. invertY?: boolean | undefined;
  64957. /**
  64958. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64959. */
  64960. samplingMode: number;
  64961. /**
  64962. * Gets the loaded texture
  64963. */
  64964. texture: Texture;
  64965. /**
  64966. * Callback called when the task is successful
  64967. */
  64968. onSuccess: (task: TextureAssetTask) => void;
  64969. /**
  64970. * Callback called when the task is successful
  64971. */
  64972. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  64973. /**
  64974. * Creates a new TextureAssetTask object
  64975. * @param name defines the name of the task
  64976. * @param url defines the location of the file to load
  64977. * @param noMipmap defines if mipmap should not be generated (default is false)
  64978. * @param invertY defines if texture must be inverted on Y axis (default is false)
  64979. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64980. */
  64981. constructor(
  64982. /**
  64983. * Defines the name of the task
  64984. */
  64985. name: string,
  64986. /**
  64987. * Defines the location of the file to load
  64988. */
  64989. url: string,
  64990. /**
  64991. * Defines if mipmap should not be generated (default is false)
  64992. */
  64993. noMipmap?: boolean | undefined,
  64994. /**
  64995. * Defines if texture must be inverted on Y axis (default is false)
  64996. */
  64997. invertY?: boolean | undefined,
  64998. /**
  64999. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65000. */
  65001. samplingMode?: number);
  65002. /**
  65003. * Execute the current task
  65004. * @param scene defines the scene where you want your assets to be loaded
  65005. * @param onSuccess is a callback called when the task is successfully executed
  65006. * @param onError is a callback called if an error occurs
  65007. */
  65008. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65009. }
  65010. /**
  65011. * Define a task used by AssetsManager to load cube textures
  65012. */
  65013. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65014. /**
  65015. * Defines the name of the task
  65016. */
  65017. name: string;
  65018. /**
  65019. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65020. */
  65021. url: string;
  65022. /**
  65023. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65024. */
  65025. extensions?: string[] | undefined;
  65026. /**
  65027. * Defines if mipmaps should not be generated (default is false)
  65028. */
  65029. noMipmap?: boolean | undefined;
  65030. /**
  65031. * Defines the explicit list of files (undefined by default)
  65032. */
  65033. files?: string[] | undefined;
  65034. /**
  65035. * Gets the loaded texture
  65036. */
  65037. texture: CubeTexture;
  65038. /**
  65039. * Callback called when the task is successful
  65040. */
  65041. onSuccess: (task: CubeTextureAssetTask) => void;
  65042. /**
  65043. * Callback called when the task is successful
  65044. */
  65045. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  65046. /**
  65047. * Creates a new CubeTextureAssetTask
  65048. * @param name defines the name of the task
  65049. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65050. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65051. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65052. * @param files defines the explicit list of files (undefined by default)
  65053. */
  65054. constructor(
  65055. /**
  65056. * Defines the name of the task
  65057. */
  65058. name: string,
  65059. /**
  65060. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65061. */
  65062. url: string,
  65063. /**
  65064. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65065. */
  65066. extensions?: string[] | undefined,
  65067. /**
  65068. * Defines if mipmaps should not be generated (default is false)
  65069. */
  65070. noMipmap?: boolean | undefined,
  65071. /**
  65072. * Defines the explicit list of files (undefined by default)
  65073. */
  65074. files?: string[] | undefined);
  65075. /**
  65076. * Execute the current task
  65077. * @param scene defines the scene where you want your assets to be loaded
  65078. * @param onSuccess is a callback called when the task is successfully executed
  65079. * @param onError is a callback called if an error occurs
  65080. */
  65081. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65082. }
  65083. /**
  65084. * Define a task used by AssetsManager to load HDR cube textures
  65085. */
  65086. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65087. /**
  65088. * Defines the name of the task
  65089. */
  65090. name: string;
  65091. /**
  65092. * Defines the location of the file to load
  65093. */
  65094. url: string;
  65095. /**
  65096. * Defines the desired size (the more it increases the longer the generation will be)
  65097. */
  65098. size: number;
  65099. /**
  65100. * Defines if mipmaps should not be generated (default is false)
  65101. */
  65102. noMipmap: boolean;
  65103. /**
  65104. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65105. */
  65106. generateHarmonics: boolean;
  65107. /**
  65108. * 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)
  65109. */
  65110. gammaSpace: boolean;
  65111. /**
  65112. * Internal Use Only
  65113. */
  65114. reserved: boolean;
  65115. /**
  65116. * Gets the loaded texture
  65117. */
  65118. texture: HDRCubeTexture;
  65119. /**
  65120. * Callback called when the task is successful
  65121. */
  65122. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65123. /**
  65124. * Callback called when the task is successful
  65125. */
  65126. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65127. /**
  65128. * Creates a new HDRCubeTextureAssetTask object
  65129. * @param name defines the name of the task
  65130. * @param url defines the location of the file to load
  65131. * @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.
  65132. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65133. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65134. * @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)
  65135. * @param reserved Internal use only
  65136. */
  65137. constructor(
  65138. /**
  65139. * Defines the name of the task
  65140. */
  65141. name: string,
  65142. /**
  65143. * Defines the location of the file to load
  65144. */
  65145. url: string,
  65146. /**
  65147. * Defines the desired size (the more it increases the longer the generation will be)
  65148. */
  65149. size: number,
  65150. /**
  65151. * Defines if mipmaps should not be generated (default is false)
  65152. */
  65153. noMipmap?: boolean,
  65154. /**
  65155. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65156. */
  65157. generateHarmonics?: boolean,
  65158. /**
  65159. * 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)
  65160. */
  65161. gammaSpace?: boolean,
  65162. /**
  65163. * Internal Use Only
  65164. */
  65165. reserved?: boolean);
  65166. /**
  65167. * Execute the current task
  65168. * @param scene defines the scene where you want your assets to be loaded
  65169. * @param onSuccess is a callback called when the task is successfully executed
  65170. * @param onError is a callback called if an error occurs
  65171. */
  65172. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65173. }
  65174. /**
  65175. * Define a task used by AssetsManager to load Equirectangular cube textures
  65176. */
  65177. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65178. /**
  65179. * Defines the name of the task
  65180. */
  65181. name: string;
  65182. /**
  65183. * Defines the location of the file to load
  65184. */
  65185. url: string;
  65186. /**
  65187. * Defines the desired size (the more it increases the longer the generation will be)
  65188. */
  65189. size: number;
  65190. /**
  65191. * Defines if mipmaps should not be generated (default is false)
  65192. */
  65193. noMipmap: boolean;
  65194. /**
  65195. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65196. * but the standard material would require them in Gamma space) (default is true)
  65197. */
  65198. gammaSpace: boolean;
  65199. /**
  65200. * Gets the loaded texture
  65201. */
  65202. texture: EquiRectangularCubeTexture;
  65203. /**
  65204. * Callback called when the task is successful
  65205. */
  65206. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65207. /**
  65208. * Callback called when the task is successful
  65209. */
  65210. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65211. /**
  65212. * Creates a new EquiRectangularCubeTextureAssetTask object
  65213. * @param name defines the name of the task
  65214. * @param url defines the location of the file to load
  65215. * @param size defines the desired size (the more it increases the longer the generation will be)
  65216. * If the size is omitted this implies you are using a preprocessed cubemap.
  65217. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65218. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65219. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65220. * (default is true)
  65221. */
  65222. constructor(
  65223. /**
  65224. * Defines the name of the task
  65225. */
  65226. name: string,
  65227. /**
  65228. * Defines the location of the file to load
  65229. */
  65230. url: string,
  65231. /**
  65232. * Defines the desired size (the more it increases the longer the generation will be)
  65233. */
  65234. size: number,
  65235. /**
  65236. * Defines if mipmaps should not be generated (default is false)
  65237. */
  65238. noMipmap?: boolean,
  65239. /**
  65240. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65241. * but the standard material would require them in Gamma space) (default is true)
  65242. */
  65243. gammaSpace?: boolean);
  65244. /**
  65245. * Execute the current task
  65246. * @param scene defines the scene where you want your assets to be loaded
  65247. * @param onSuccess is a callback called when the task is successfully executed
  65248. * @param onError is a callback called if an error occurs
  65249. */
  65250. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65251. }
  65252. /**
  65253. * This class can be used to easily import assets into a scene
  65254. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65255. */
  65256. export class AssetsManager {
  65257. private _scene;
  65258. private _isLoading;
  65259. protected _tasks: AbstractAssetTask[];
  65260. protected _waitingTasksCount: number;
  65261. protected _totalTasksCount: number;
  65262. /**
  65263. * Callback called when all tasks are processed
  65264. */
  65265. onFinish: (tasks: AbstractAssetTask[]) => void;
  65266. /**
  65267. * Callback called when a task is successful
  65268. */
  65269. onTaskSuccess: (task: AbstractAssetTask) => void;
  65270. /**
  65271. * Callback called when a task had an error
  65272. */
  65273. onTaskError: (task: AbstractAssetTask) => void;
  65274. /**
  65275. * Callback called when a task is done (whatever the result is)
  65276. */
  65277. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65278. /**
  65279. * Observable called when all tasks are processed
  65280. */
  65281. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65282. /**
  65283. * Observable called when a task had an error
  65284. */
  65285. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65286. /**
  65287. * Observable called when all tasks were executed
  65288. */
  65289. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65290. /**
  65291. * Observable called when a task is done (whatever the result is)
  65292. */
  65293. onProgressObservable: Observable<IAssetsProgressEvent>;
  65294. /**
  65295. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65296. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65297. */
  65298. useDefaultLoadingScreen: boolean;
  65299. /**
  65300. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65301. * when all assets have been downloaded.
  65302. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65303. */
  65304. autoHideLoadingUI: boolean;
  65305. /**
  65306. * Creates a new AssetsManager
  65307. * @param scene defines the scene to work on
  65308. */
  65309. constructor(scene: Scene);
  65310. /**
  65311. * Add a MeshAssetTask to the list of active tasks
  65312. * @param taskName defines the name of the new task
  65313. * @param meshesNames defines the name of meshes to load
  65314. * @param rootUrl defines the root url to use to locate files
  65315. * @param sceneFilename defines the filename of the scene file
  65316. * @returns a new MeshAssetTask object
  65317. */
  65318. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65319. /**
  65320. * Add a TextFileAssetTask to the list of active tasks
  65321. * @param taskName defines the name of the new task
  65322. * @param url defines the url of the file to load
  65323. * @returns a new TextFileAssetTask object
  65324. */
  65325. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65326. /**
  65327. * Add a BinaryFileAssetTask to the list of active tasks
  65328. * @param taskName defines the name of the new task
  65329. * @param url defines the url of the file to load
  65330. * @returns a new BinaryFileAssetTask object
  65331. */
  65332. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65333. /**
  65334. * Add a ImageAssetTask 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 ImageAssetTask object
  65338. */
  65339. addImageTask(taskName: string, url: string): ImageAssetTask;
  65340. /**
  65341. * Add a TextureAssetTask 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. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65345. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65346. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65347. * @returns a new TextureAssetTask object
  65348. */
  65349. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65350. /**
  65351. * Add a CubeTextureAssetTask to the list of active tasks
  65352. * @param taskName defines the name of the new task
  65353. * @param url defines the url of the file to load
  65354. * @param extensions defines the extension to use to load the cube map (can be null)
  65355. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65356. * @param files defines the list of files to load (can be null)
  65357. * @returns a new CubeTextureAssetTask object
  65358. */
  65359. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  65360. /**
  65361. *
  65362. * Add a HDRCubeTextureAssetTask to the list of active tasks
  65363. * @param taskName defines the name of the new task
  65364. * @param url defines the url of the file to load
  65365. * @param size defines the size you want for the cubemap (can be null)
  65366. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65367. * @param generateHarmonics defines if you want to automatically generate (true by default)
  65368. * @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)
  65369. * @param reserved Internal use only
  65370. * @returns a new HDRCubeTextureAssetTask object
  65371. */
  65372. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  65373. /**
  65374. *
  65375. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  65376. * @param taskName defines the name of the new task
  65377. * @param url defines the url of the file to load
  65378. * @param size defines the size you want for the cubemap (can be null)
  65379. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65380. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65381. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65382. * @returns a new EquiRectangularCubeTextureAssetTask object
  65383. */
  65384. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  65385. /**
  65386. * Remove a task from the assets manager.
  65387. * @param task the task to remove
  65388. */
  65389. removeTask(task: AbstractAssetTask): void;
  65390. private _decreaseWaitingTasksCount;
  65391. private _runTask;
  65392. /**
  65393. * Reset the AssetsManager and remove all tasks
  65394. * @return the current instance of the AssetsManager
  65395. */
  65396. reset(): AssetsManager;
  65397. /**
  65398. * Start the loading process
  65399. * @return the current instance of the AssetsManager
  65400. */
  65401. load(): AssetsManager;
  65402. /**
  65403. * Start the loading process as an async operation
  65404. * @return a promise returning the list of failed tasks
  65405. */
  65406. loadAsync(): Promise<void>;
  65407. }
  65408. }
  65409. declare module "babylonjs/Misc/deferred" {
  65410. /**
  65411. * Wrapper class for promise with external resolve and reject.
  65412. */
  65413. export class Deferred<T> {
  65414. /**
  65415. * The promise associated with this deferred object.
  65416. */
  65417. readonly promise: Promise<T>;
  65418. private _resolve;
  65419. private _reject;
  65420. /**
  65421. * The resolve method of the promise associated with this deferred object.
  65422. */
  65423. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  65424. /**
  65425. * The reject method of the promise associated with this deferred object.
  65426. */
  65427. readonly reject: (reason?: any) => void;
  65428. /**
  65429. * Constructor for this deferred object.
  65430. */
  65431. constructor();
  65432. }
  65433. }
  65434. declare module "babylonjs/Misc/meshExploder" {
  65435. import { Mesh } from "babylonjs/Meshes/mesh";
  65436. /**
  65437. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  65438. */
  65439. export class MeshExploder {
  65440. private _centerMesh;
  65441. private _meshes;
  65442. private _meshesOrigins;
  65443. private _toCenterVectors;
  65444. private _scaledDirection;
  65445. private _newPosition;
  65446. private _centerPosition;
  65447. /**
  65448. * Explodes meshes from a center mesh.
  65449. * @param meshes The meshes to explode.
  65450. * @param centerMesh The mesh to be center of explosion.
  65451. */
  65452. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  65453. private _setCenterMesh;
  65454. /**
  65455. * Get class name
  65456. * @returns "MeshExploder"
  65457. */
  65458. getClassName(): string;
  65459. /**
  65460. * "Exploded meshes"
  65461. * @returns Array of meshes with the centerMesh at index 0.
  65462. */
  65463. getMeshes(): Array<Mesh>;
  65464. /**
  65465. * Explodes meshes giving a specific direction
  65466. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  65467. */
  65468. explode(direction?: number): void;
  65469. }
  65470. }
  65471. declare module "babylonjs/Misc/filesInput" {
  65472. import { Engine } from "babylonjs/Engines/engine";
  65473. import { Scene } from "babylonjs/scene";
  65474. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  65475. /**
  65476. * Class used to help managing file picking and drag'n'drop
  65477. */
  65478. export class FilesInput {
  65479. /**
  65480. * List of files ready to be loaded
  65481. */
  65482. static readonly FilesToLoad: {
  65483. [key: string]: File;
  65484. };
  65485. /**
  65486. * Callback called when a file is processed
  65487. */
  65488. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  65489. private _engine;
  65490. private _currentScene;
  65491. private _sceneLoadedCallback;
  65492. private _progressCallback;
  65493. private _additionalRenderLoopLogicCallback;
  65494. private _textureLoadingCallback;
  65495. private _startingProcessingFilesCallback;
  65496. private _onReloadCallback;
  65497. private _errorCallback;
  65498. private _elementToMonitor;
  65499. private _sceneFileToLoad;
  65500. private _filesToLoad;
  65501. /**
  65502. * Creates a new FilesInput
  65503. * @param engine defines the rendering engine
  65504. * @param scene defines the hosting scene
  65505. * @param sceneLoadedCallback callback called when scene is loaded
  65506. * @param progressCallback callback called to track progress
  65507. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  65508. * @param textureLoadingCallback callback called when a texture is loading
  65509. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  65510. * @param onReloadCallback callback called when a reload is requested
  65511. * @param errorCallback callback call if an error occurs
  65512. */
  65513. 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);
  65514. private _dragEnterHandler;
  65515. private _dragOverHandler;
  65516. private _dropHandler;
  65517. /**
  65518. * Calls this function to listen to drag'n'drop events on a specific DOM element
  65519. * @param elementToMonitor defines the DOM element to track
  65520. */
  65521. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  65522. /**
  65523. * Release all associated resources
  65524. */
  65525. dispose(): void;
  65526. private renderFunction;
  65527. private drag;
  65528. private drop;
  65529. private _traverseFolder;
  65530. private _processFiles;
  65531. /**
  65532. * Load files from a drop event
  65533. * @param event defines the drop event to use as source
  65534. */
  65535. loadFiles(event: any): void;
  65536. private _processReload;
  65537. /**
  65538. * Reload the current scene from the loaded files
  65539. */
  65540. reload(): void;
  65541. }
  65542. }
  65543. declare module "babylonjs/Misc/HighDynamicRange/index" {
  65544. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  65545. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  65546. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  65547. }
  65548. declare module "babylonjs/Misc/sceneOptimizer" {
  65549. import { Scene, IDisposable } from "babylonjs/scene";
  65550. import { Observable } from "babylonjs/Misc/observable";
  65551. /**
  65552. * Defines the root class used to create scene optimization to use with SceneOptimizer
  65553. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65554. */
  65555. export class SceneOptimization {
  65556. /**
  65557. * Defines the priority of this optimization (0 by default which means first in the list)
  65558. */
  65559. priority: number;
  65560. /**
  65561. * Gets a string describing the action executed by the current optimization
  65562. * @returns description string
  65563. */
  65564. getDescription(): string;
  65565. /**
  65566. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65567. * @param scene defines the current scene where to apply this optimization
  65568. * @param optimizer defines the current optimizer
  65569. * @returns true if everything that can be done was applied
  65570. */
  65571. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65572. /**
  65573. * Creates the SceneOptimization object
  65574. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65575. * @param desc defines the description associated with the optimization
  65576. */
  65577. constructor(
  65578. /**
  65579. * Defines the priority of this optimization (0 by default which means first in the list)
  65580. */
  65581. priority?: number);
  65582. }
  65583. /**
  65584. * Defines an optimization used to reduce the size of render target textures
  65585. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65586. */
  65587. export class TextureOptimization extends SceneOptimization {
  65588. /**
  65589. * Defines the priority of this optimization (0 by default which means first in the list)
  65590. */
  65591. priority: number;
  65592. /**
  65593. * 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
  65594. */
  65595. maximumSize: number;
  65596. /**
  65597. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65598. */
  65599. step: number;
  65600. /**
  65601. * Gets a string describing the action executed by the current optimization
  65602. * @returns description string
  65603. */
  65604. getDescription(): string;
  65605. /**
  65606. * Creates the TextureOptimization object
  65607. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65608. * @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
  65609. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65610. */
  65611. constructor(
  65612. /**
  65613. * Defines the priority of this optimization (0 by default which means first in the list)
  65614. */
  65615. priority?: number,
  65616. /**
  65617. * 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
  65618. */
  65619. maximumSize?: number,
  65620. /**
  65621. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65622. */
  65623. step?: number);
  65624. /**
  65625. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65626. * @param scene defines the current scene where to apply this optimization
  65627. * @param optimizer defines the current optimizer
  65628. * @returns true if everything that can be done was applied
  65629. */
  65630. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65631. }
  65632. /**
  65633. * Defines an optimization used to increase or decrease the rendering resolution
  65634. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65635. */
  65636. export class HardwareScalingOptimization extends SceneOptimization {
  65637. /**
  65638. * Defines the priority of this optimization (0 by default which means first in the list)
  65639. */
  65640. priority: number;
  65641. /**
  65642. * Defines the maximum scale to use (2 by default)
  65643. */
  65644. maximumScale: number;
  65645. /**
  65646. * Defines the step to use between two passes (0.5 by default)
  65647. */
  65648. step: number;
  65649. private _currentScale;
  65650. private _directionOffset;
  65651. /**
  65652. * Gets a string describing the action executed by the current optimization
  65653. * @return description string
  65654. */
  65655. getDescription(): string;
  65656. /**
  65657. * Creates the HardwareScalingOptimization object
  65658. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65659. * @param maximumScale defines the maximum scale to use (2 by default)
  65660. * @param step defines the step to use between two passes (0.5 by default)
  65661. */
  65662. constructor(
  65663. /**
  65664. * Defines the priority of this optimization (0 by default which means first in the list)
  65665. */
  65666. priority?: number,
  65667. /**
  65668. * Defines the maximum scale to use (2 by default)
  65669. */
  65670. maximumScale?: number,
  65671. /**
  65672. * Defines the step to use between two passes (0.5 by default)
  65673. */
  65674. step?: number);
  65675. /**
  65676. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65677. * @param scene defines the current scene where to apply this optimization
  65678. * @param optimizer defines the current optimizer
  65679. * @returns true if everything that can be done was applied
  65680. */
  65681. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65682. }
  65683. /**
  65684. * Defines an optimization used to remove shadows
  65685. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65686. */
  65687. export class ShadowsOptimization extends SceneOptimization {
  65688. /**
  65689. * Gets a string describing the action executed by the current optimization
  65690. * @return description string
  65691. */
  65692. getDescription(): string;
  65693. /**
  65694. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65695. * @param scene defines the current scene where to apply this optimization
  65696. * @param optimizer defines the current optimizer
  65697. * @returns true if everything that can be done was applied
  65698. */
  65699. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65700. }
  65701. /**
  65702. * Defines an optimization used to turn post-processes off
  65703. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65704. */
  65705. export class PostProcessesOptimization extends SceneOptimization {
  65706. /**
  65707. * Gets a string describing the action executed by the current optimization
  65708. * @return description string
  65709. */
  65710. getDescription(): string;
  65711. /**
  65712. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65713. * @param scene defines the current scene where to apply this optimization
  65714. * @param optimizer defines the current optimizer
  65715. * @returns true if everything that can be done was applied
  65716. */
  65717. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65718. }
  65719. /**
  65720. * Defines an optimization used to turn lens flares off
  65721. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65722. */
  65723. export class LensFlaresOptimization extends SceneOptimization {
  65724. /**
  65725. * Gets a string describing the action executed by the current optimization
  65726. * @return description string
  65727. */
  65728. getDescription(): string;
  65729. /**
  65730. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65731. * @param scene defines the current scene where to apply this optimization
  65732. * @param optimizer defines the current optimizer
  65733. * @returns true if everything that can be done was applied
  65734. */
  65735. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65736. }
  65737. /**
  65738. * Defines an optimization based on user defined callback.
  65739. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65740. */
  65741. export class CustomOptimization extends SceneOptimization {
  65742. /**
  65743. * Callback called to apply the custom optimization.
  65744. */
  65745. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  65746. /**
  65747. * Callback called to get custom description
  65748. */
  65749. onGetDescription: () => string;
  65750. /**
  65751. * Gets a string describing the action executed by the current optimization
  65752. * @returns description string
  65753. */
  65754. getDescription(): string;
  65755. /**
  65756. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65757. * @param scene defines the current scene where to apply this optimization
  65758. * @param optimizer defines the current optimizer
  65759. * @returns true if everything that can be done was applied
  65760. */
  65761. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65762. }
  65763. /**
  65764. * Defines an optimization used to turn particles off
  65765. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65766. */
  65767. export class ParticlesOptimization extends SceneOptimization {
  65768. /**
  65769. * Gets a string describing the action executed by the current optimization
  65770. * @return description string
  65771. */
  65772. getDescription(): string;
  65773. /**
  65774. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65775. * @param scene defines the current scene where to apply this optimization
  65776. * @param optimizer defines the current optimizer
  65777. * @returns true if everything that can be done was applied
  65778. */
  65779. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65780. }
  65781. /**
  65782. * Defines an optimization used to turn render targets off
  65783. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65784. */
  65785. export class RenderTargetsOptimization extends SceneOptimization {
  65786. /**
  65787. * Gets a string describing the action executed by the current optimization
  65788. * @return description string
  65789. */
  65790. getDescription(): string;
  65791. /**
  65792. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65793. * @param scene defines the current scene where to apply this optimization
  65794. * @param optimizer defines the current optimizer
  65795. * @returns true if everything that can be done was applied
  65796. */
  65797. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65798. }
  65799. /**
  65800. * Defines an optimization used to merge meshes with compatible materials
  65801. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65802. */
  65803. export class MergeMeshesOptimization extends SceneOptimization {
  65804. private static _UpdateSelectionTree;
  65805. /**
  65806. * Gets or sets a boolean which defines if optimization octree has to be updated
  65807. */
  65808. /**
  65809. * Gets or sets a boolean which defines if optimization octree has to be updated
  65810. */
  65811. static UpdateSelectionTree: boolean;
  65812. /**
  65813. * Gets a string describing the action executed by the current optimization
  65814. * @return description string
  65815. */
  65816. getDescription(): string;
  65817. private _canBeMerged;
  65818. /**
  65819. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65820. * @param scene defines the current scene where to apply this optimization
  65821. * @param optimizer defines the current optimizer
  65822. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  65823. * @returns true if everything that can be done was applied
  65824. */
  65825. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  65826. }
  65827. /**
  65828. * Defines a list of options used by SceneOptimizer
  65829. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65830. */
  65831. export class SceneOptimizerOptions {
  65832. /**
  65833. * Defines the target frame rate to reach (60 by default)
  65834. */
  65835. targetFrameRate: number;
  65836. /**
  65837. * Defines the interval between two checkes (2000ms by default)
  65838. */
  65839. trackerDuration: number;
  65840. /**
  65841. * Gets the list of optimizations to apply
  65842. */
  65843. optimizations: SceneOptimization[];
  65844. /**
  65845. * Creates a new list of options used by SceneOptimizer
  65846. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  65847. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  65848. */
  65849. constructor(
  65850. /**
  65851. * Defines the target frame rate to reach (60 by default)
  65852. */
  65853. targetFrameRate?: number,
  65854. /**
  65855. * Defines the interval between two checkes (2000ms by default)
  65856. */
  65857. trackerDuration?: number);
  65858. /**
  65859. * Add a new optimization
  65860. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  65861. * @returns the current SceneOptimizerOptions
  65862. */
  65863. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  65864. /**
  65865. * Add a new custom optimization
  65866. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  65867. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  65868. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65869. * @returns the current SceneOptimizerOptions
  65870. */
  65871. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  65872. /**
  65873. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  65874. * @param targetFrameRate defines the target frame rate (60 by default)
  65875. * @returns a SceneOptimizerOptions object
  65876. */
  65877. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65878. /**
  65879. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  65880. * @param targetFrameRate defines the target frame rate (60 by default)
  65881. * @returns a SceneOptimizerOptions object
  65882. */
  65883. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65884. /**
  65885. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  65886. * @param targetFrameRate defines the target frame rate (60 by default)
  65887. * @returns a SceneOptimizerOptions object
  65888. */
  65889. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65890. }
  65891. /**
  65892. * Class used to run optimizations in order to reach a target frame rate
  65893. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65894. */
  65895. export class SceneOptimizer implements IDisposable {
  65896. private _isRunning;
  65897. private _options;
  65898. private _scene;
  65899. private _currentPriorityLevel;
  65900. private _targetFrameRate;
  65901. private _trackerDuration;
  65902. private _currentFrameRate;
  65903. private _sceneDisposeObserver;
  65904. private _improvementMode;
  65905. /**
  65906. * Defines an observable called when the optimizer reaches the target frame rate
  65907. */
  65908. onSuccessObservable: Observable<SceneOptimizer>;
  65909. /**
  65910. * Defines an observable called when the optimizer enables an optimization
  65911. */
  65912. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  65913. /**
  65914. * Defines an observable called when the optimizer is not able to reach the target frame rate
  65915. */
  65916. onFailureObservable: Observable<SceneOptimizer>;
  65917. /**
  65918. * Gets a boolean indicating if the optimizer is in improvement mode
  65919. */
  65920. readonly isInImprovementMode: boolean;
  65921. /**
  65922. * Gets the current priority level (0 at start)
  65923. */
  65924. readonly currentPriorityLevel: number;
  65925. /**
  65926. * Gets the current frame rate checked by the SceneOptimizer
  65927. */
  65928. readonly currentFrameRate: number;
  65929. /**
  65930. * Gets or sets the current target frame rate (60 by default)
  65931. */
  65932. /**
  65933. * Gets or sets the current target frame rate (60 by default)
  65934. */
  65935. targetFrameRate: number;
  65936. /**
  65937. * Gets or sets the current interval between two checks (every 2000ms by default)
  65938. */
  65939. /**
  65940. * Gets or sets the current interval between two checks (every 2000ms by default)
  65941. */
  65942. trackerDuration: number;
  65943. /**
  65944. * Gets the list of active optimizations
  65945. */
  65946. readonly optimizations: SceneOptimization[];
  65947. /**
  65948. * Creates a new SceneOptimizer
  65949. * @param scene defines the scene to work on
  65950. * @param options defines the options to use with the SceneOptimizer
  65951. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  65952. * @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)
  65953. */
  65954. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  65955. /**
  65956. * Stops the current optimizer
  65957. */
  65958. stop(): void;
  65959. /**
  65960. * Reset the optimizer to initial step (current priority level = 0)
  65961. */
  65962. reset(): void;
  65963. /**
  65964. * Start the optimizer. By default it will try to reach a specific framerate
  65965. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  65966. */
  65967. start(): void;
  65968. private _checkCurrentState;
  65969. /**
  65970. * Release all resources
  65971. */
  65972. dispose(): void;
  65973. /**
  65974. * Helper function to create a SceneOptimizer with one single line of code
  65975. * @param scene defines the scene to work on
  65976. * @param options defines the options to use with the SceneOptimizer
  65977. * @param onSuccess defines a callback to call on success
  65978. * @param onFailure defines a callback to call on failure
  65979. * @returns the new SceneOptimizer object
  65980. */
  65981. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  65982. }
  65983. }
  65984. declare module "babylonjs/Misc/sceneSerializer" {
  65985. import { Scene } from "babylonjs/scene";
  65986. /**
  65987. * Class used to serialize a scene into a string
  65988. */
  65989. export class SceneSerializer {
  65990. /**
  65991. * Clear cache used by a previous serialization
  65992. */
  65993. static ClearCache(): void;
  65994. /**
  65995. * Serialize a scene into a JSON compatible object
  65996. * @param scene defines the scene to serialize
  65997. * @returns a JSON compatible object
  65998. */
  65999. static Serialize(scene: Scene): any;
  66000. /**
  66001. * Serialize a mesh into a JSON compatible object
  66002. * @param toSerialize defines the mesh to serialize
  66003. * @param withParents defines if parents must be serialized as well
  66004. * @param withChildren defines if children must be serialized as well
  66005. * @returns a JSON compatible object
  66006. */
  66007. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66008. }
  66009. }
  66010. declare module "babylonjs/Misc/textureTools" {
  66011. import { Texture } from "babylonjs/Materials/Textures/texture";
  66012. /**
  66013. * Class used to host texture specific utilities
  66014. */
  66015. export class TextureTools {
  66016. /**
  66017. * Uses the GPU to create a copy texture rescaled at a given size
  66018. * @param texture Texture to copy from
  66019. * @param width defines the desired width
  66020. * @param height defines the desired height
  66021. * @param useBilinearMode defines if bilinear mode has to be used
  66022. * @return the generated texture
  66023. */
  66024. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  66025. }
  66026. }
  66027. declare module "babylonjs/Misc/videoRecorder" {
  66028. import { Nullable } from "babylonjs/types";
  66029. import { Engine } from "babylonjs/Engines/engine";
  66030. /**
  66031. * This represents the different options available for the video capture.
  66032. */
  66033. export interface VideoRecorderOptions {
  66034. /** Defines the mime type of the video. */
  66035. mimeType: string;
  66036. /** Defines the FPS the video should be recorded at. */
  66037. fps: number;
  66038. /** Defines the chunk size for the recording data. */
  66039. recordChunckSize: number;
  66040. /** The audio tracks to attach to the recording. */
  66041. audioTracks?: MediaStreamTrack[];
  66042. }
  66043. /**
  66044. * This can help with recording videos from BabylonJS.
  66045. * This is based on the available WebRTC functionalities of the browser.
  66046. *
  66047. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  66048. */
  66049. export class VideoRecorder {
  66050. private static readonly _defaultOptions;
  66051. /**
  66052. * Returns whether or not the VideoRecorder is available in your browser.
  66053. * @param engine Defines the Babylon Engine.
  66054. * @returns true if supported otherwise false.
  66055. */
  66056. static IsSupported(engine: Engine): boolean;
  66057. private readonly _options;
  66058. private _canvas;
  66059. private _mediaRecorder;
  66060. private _recordedChunks;
  66061. private _fileName;
  66062. private _resolve;
  66063. private _reject;
  66064. /**
  66065. * True when a recording is already in progress.
  66066. */
  66067. readonly isRecording: boolean;
  66068. /**
  66069. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66070. * @param engine Defines the BabylonJS Engine you wish to record.
  66071. * @param options Defines options that can be used to customize the capture.
  66072. */
  66073. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66074. /**
  66075. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66076. */
  66077. stopRecording(): void;
  66078. /**
  66079. * Starts recording the canvas for a max duration specified in parameters.
  66080. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66081. * If null no automatic download will start and you can rely on the promise to get the data back.
  66082. * @param maxDuration Defines the maximum recording time in seconds.
  66083. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66084. * @return A promise callback at the end of the recording with the video data in Blob.
  66085. */
  66086. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66087. /**
  66088. * Releases internal resources used during the recording.
  66089. */
  66090. dispose(): void;
  66091. private _handleDataAvailable;
  66092. private _handleError;
  66093. private _handleStop;
  66094. }
  66095. }
  66096. declare module "babylonjs/Misc/screenshotTools" {
  66097. import { Camera } from "babylonjs/Cameras/camera";
  66098. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  66099. import { Engine } from "babylonjs/Engines/engine";
  66100. /**
  66101. * Class containing a set of static utilities functions for screenshots
  66102. */
  66103. export class ScreenshotTools {
  66104. /**
  66105. * Captures a screenshot of the current rendering
  66106. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66107. * @param engine defines the rendering engine
  66108. * @param camera defines the source camera
  66109. * @param size This parameter can be set to a single number or to an object with the
  66110. * following (optional) properties: precision, width, height. If a single number is passed,
  66111. * it will be used for both width and height. If an object is passed, the screenshot size
  66112. * will be derived from the parameters. The precision property is a multiplier allowing
  66113. * rendering at a higher or lower resolution
  66114. * @param successCallback defines the callback receives a single parameter which contains the
  66115. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66116. * src parameter of an <img> to display it
  66117. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66118. * Check your browser for supported MIME types
  66119. */
  66120. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66121. /**
  66122. * Captures a screenshot of the current rendering
  66123. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66124. * @param engine defines the rendering engine
  66125. * @param camera defines the source camera
  66126. * @param size This parameter can be set to a single number or to an object with the
  66127. * following (optional) properties: precision, width, height. If a single number is passed,
  66128. * it will be used for both width and height. If an object is passed, the screenshot size
  66129. * will be derived from the parameters. The precision property is a multiplier allowing
  66130. * rendering at a higher or lower resolution
  66131. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66132. * Check your browser for supported MIME types
  66133. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66134. * to the src parameter of an <img> to display it
  66135. */
  66136. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66137. /**
  66138. * Generates an image screenshot from the specified camera.
  66139. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66140. * @param engine The engine to use for rendering
  66141. * @param camera The camera to use for rendering
  66142. * @param size This parameter can be set to a single number or to an object with the
  66143. * following (optional) properties: precision, width, height. If a single number is passed,
  66144. * it will be used for both width and height. If an object is passed, the screenshot size
  66145. * will be derived from the parameters. The precision property is a multiplier allowing
  66146. * rendering at a higher or lower resolution
  66147. * @param successCallback The callback receives a single parameter which contains the
  66148. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66149. * src parameter of an <img> to display it
  66150. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66151. * Check your browser for supported MIME types
  66152. * @param samples Texture samples (default: 1)
  66153. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66154. * @param fileName A name for for the downloaded file.
  66155. */
  66156. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66157. /**
  66158. * Generates an image screenshot from the specified camera.
  66159. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66160. * @param engine The engine to use for rendering
  66161. * @param camera The camera to use for rendering
  66162. * @param size This parameter can be set to a single number or to an object with the
  66163. * following (optional) properties: precision, width, height. If a single number is passed,
  66164. * it will be used for both width and height. If an object is passed, the screenshot size
  66165. * will be derived from the parameters. The precision property is a multiplier allowing
  66166. * rendering at a higher or lower resolution
  66167. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66168. * Check your browser for supported MIME types
  66169. * @param samples Texture samples (default: 1)
  66170. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66171. * @param fileName A name for for the downloaded file.
  66172. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66173. * to the src parameter of an <img> to display it
  66174. */
  66175. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66176. /**
  66177. * Gets height and width for screenshot size
  66178. * @private
  66179. */
  66180. private static _getScreenshotSize;
  66181. }
  66182. }
  66183. declare module "babylonjs/Misc/index" {
  66184. export * from "babylonjs/Misc/andOrNotEvaluator";
  66185. export * from "babylonjs/Misc/assetsManager";
  66186. export * from "babylonjs/Misc/dds";
  66187. export * from "babylonjs/Misc/decorators";
  66188. export * from "babylonjs/Misc/deferred";
  66189. export * from "babylonjs/Misc/environmentTextureTools";
  66190. export * from "babylonjs/Misc/meshExploder";
  66191. export * from "babylonjs/Misc/filesInput";
  66192. export * from "babylonjs/Misc/HighDynamicRange/index";
  66193. export * from "babylonjs/Misc/khronosTextureContainer";
  66194. export * from "babylonjs/Misc/observable";
  66195. export * from "babylonjs/Misc/performanceMonitor";
  66196. export * from "babylonjs/Misc/promise";
  66197. export * from "babylonjs/Misc/sceneOptimizer";
  66198. export * from "babylonjs/Misc/sceneSerializer";
  66199. export * from "babylonjs/Misc/smartArray";
  66200. export * from "babylonjs/Misc/stringDictionary";
  66201. export * from "babylonjs/Misc/tags";
  66202. export * from "babylonjs/Misc/textureTools";
  66203. export * from "babylonjs/Misc/tga";
  66204. export * from "babylonjs/Misc/tools";
  66205. export * from "babylonjs/Misc/videoRecorder";
  66206. export * from "babylonjs/Misc/virtualJoystick";
  66207. export * from "babylonjs/Misc/workerPool";
  66208. export * from "babylonjs/Misc/logger";
  66209. export * from "babylonjs/Misc/typeStore";
  66210. export * from "babylonjs/Misc/filesInputStore";
  66211. export * from "babylonjs/Misc/deepCopier";
  66212. export * from "babylonjs/Misc/pivotTools";
  66213. export * from "babylonjs/Misc/precisionDate";
  66214. export * from "babylonjs/Misc/screenshotTools";
  66215. export * from "babylonjs/Misc/typeStore";
  66216. export * from "babylonjs/Misc/webRequest";
  66217. export * from "babylonjs/Misc/iInspectable";
  66218. export * from "babylonjs/Misc/brdfTextureTools";
  66219. export * from "babylonjs/Misc/rgbdTextureTools";
  66220. export * from "babylonjs/Misc/gradients";
  66221. export * from "babylonjs/Misc/perfCounter";
  66222. export * from "babylonjs/Misc/fileRequest";
  66223. export * from "babylonjs/Misc/customAnimationFrameRequester";
  66224. export * from "babylonjs/Misc/retryStrategy";
  66225. export * from "babylonjs/Misc/loadFileError";
  66226. export * from "babylonjs/Misc/interfaces/screenshotSize";
  66227. }
  66228. declare module "babylonjs/index" {
  66229. export * from "babylonjs/abstractScene";
  66230. export * from "babylonjs/Actions/index";
  66231. export * from "babylonjs/Animations/index";
  66232. export * from "babylonjs/assetContainer";
  66233. export * from "babylonjs/Audio/index";
  66234. export * from "babylonjs/Behaviors/index";
  66235. export * from "babylonjs/Bones/index";
  66236. export * from "babylonjs/Cameras/index";
  66237. export * from "babylonjs/Collisions/index";
  66238. export * from "babylonjs/Culling/index";
  66239. export * from "babylonjs/Debug/index";
  66240. export * from "babylonjs/Engines/index";
  66241. export * from "babylonjs/Events/index";
  66242. export * from "babylonjs/Gamepads/index";
  66243. export * from "babylonjs/Gizmos/index";
  66244. export * from "babylonjs/Helpers/index";
  66245. export * from "babylonjs/Instrumentation/index";
  66246. export * from "babylonjs/Layers/index";
  66247. export * from "babylonjs/LensFlares/index";
  66248. export * from "babylonjs/Lights/index";
  66249. export * from "babylonjs/Loading/index";
  66250. export * from "babylonjs/Materials/index";
  66251. export * from "babylonjs/Maths/index";
  66252. export * from "babylonjs/Meshes/index";
  66253. export * from "babylonjs/Morph/index";
  66254. export * from "babylonjs/Navigation/index";
  66255. export * from "babylonjs/node";
  66256. export * from "babylonjs/Offline/index";
  66257. export * from "babylonjs/Particles/index";
  66258. export * from "babylonjs/Physics/index";
  66259. export * from "babylonjs/PostProcesses/index";
  66260. export * from "babylonjs/Probes/index";
  66261. export * from "babylonjs/Rendering/index";
  66262. export * from "babylonjs/scene";
  66263. export * from "babylonjs/sceneComponent";
  66264. export * from "babylonjs/Sprites/index";
  66265. export * from "babylonjs/States/index";
  66266. export * from "babylonjs/Misc/index";
  66267. export * from "babylonjs/types";
  66268. }
  66269. declare module "babylonjs/Animations/pathCursor" {
  66270. import { Vector3 } from "babylonjs/Maths/math.vector";
  66271. import { Path2 } from "babylonjs/Maths/math.path";
  66272. /**
  66273. * A cursor which tracks a point on a path
  66274. */
  66275. export class PathCursor {
  66276. private path;
  66277. /**
  66278. * Stores path cursor callbacks for when an onchange event is triggered
  66279. */
  66280. private _onchange;
  66281. /**
  66282. * The value of the path cursor
  66283. */
  66284. value: number;
  66285. /**
  66286. * The animation array of the path cursor
  66287. */
  66288. animations: Animation[];
  66289. /**
  66290. * Initializes the path cursor
  66291. * @param path The path to track
  66292. */
  66293. constructor(path: Path2);
  66294. /**
  66295. * Gets the cursor point on the path
  66296. * @returns A point on the path cursor at the cursor location
  66297. */
  66298. getPoint(): Vector3;
  66299. /**
  66300. * Moves the cursor ahead by the step amount
  66301. * @param step The amount to move the cursor forward
  66302. * @returns This path cursor
  66303. */
  66304. moveAhead(step?: number): PathCursor;
  66305. /**
  66306. * Moves the cursor behind by the step amount
  66307. * @param step The amount to move the cursor back
  66308. * @returns This path cursor
  66309. */
  66310. moveBack(step?: number): PathCursor;
  66311. /**
  66312. * Moves the cursor by the step amount
  66313. * If the step amount is greater than one, an exception is thrown
  66314. * @param step The amount to move the cursor
  66315. * @returns This path cursor
  66316. */
  66317. move(step: number): PathCursor;
  66318. /**
  66319. * Ensures that the value is limited between zero and one
  66320. * @returns This path cursor
  66321. */
  66322. private ensureLimits;
  66323. /**
  66324. * Runs onchange callbacks on change (used by the animation engine)
  66325. * @returns This path cursor
  66326. */
  66327. private raiseOnChange;
  66328. /**
  66329. * Executes a function on change
  66330. * @param f A path cursor onchange callback
  66331. * @returns This path cursor
  66332. */
  66333. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66334. }
  66335. }
  66336. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  66337. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  66338. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  66339. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  66340. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  66341. }
  66342. declare module "babylonjs/Engines/Processors/Expressions/index" {
  66343. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  66344. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  66345. }
  66346. declare module "babylonjs/Engines/Processors/index" {
  66347. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  66348. export * from "babylonjs/Engines/Processors/Expressions/index";
  66349. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  66350. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  66351. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  66352. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  66353. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  66354. export * from "babylonjs/Engines/Processors/shaderProcessor";
  66355. }
  66356. declare module "babylonjs/Legacy/legacy" {
  66357. import * as Babylon from "babylonjs/index";
  66358. export * from "babylonjs/index";
  66359. }
  66360. declare module "babylonjs/Shaders/blur.fragment" {
  66361. /** @hidden */
  66362. export var blurPixelShader: {
  66363. name: string;
  66364. shader: string;
  66365. };
  66366. }
  66367. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  66368. /** @hidden */
  66369. export var pointCloudVertexDeclaration: {
  66370. name: string;
  66371. shader: string;
  66372. };
  66373. }
  66374. declare module "babylonjs" {
  66375. export * from "babylonjs/Legacy/legacy";
  66376. }
  66377. declare module BABYLON {
  66378. /** Alias type for value that can be null */
  66379. export type Nullable<T> = T | null;
  66380. /**
  66381. * Alias type for number that are floats
  66382. * @ignorenaming
  66383. */
  66384. export type float = number;
  66385. /**
  66386. * Alias type for number that are doubles.
  66387. * @ignorenaming
  66388. */
  66389. export type double = number;
  66390. /**
  66391. * Alias type for number that are integer
  66392. * @ignorenaming
  66393. */
  66394. export type int = number;
  66395. /** Alias type for number array or Float32Array */
  66396. export type FloatArray = number[] | Float32Array;
  66397. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  66398. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  66399. /**
  66400. * Alias for types that can be used by a Buffer or VertexBuffer.
  66401. */
  66402. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  66403. /**
  66404. * Alias type for primitive types
  66405. * @ignorenaming
  66406. */
  66407. type Primitive = undefined | null | boolean | string | number | Function;
  66408. /**
  66409. * Type modifier to make all the properties of an object Readonly
  66410. */
  66411. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  66412. /**
  66413. * Type modifier to make all the properties of an object Readonly recursively
  66414. */
  66415. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  66416. /**
  66417. * Type modifier to make object properties readonly.
  66418. */
  66419. export type DeepImmutableObject<T> = {
  66420. readonly [K in keyof T]: DeepImmutable<T[K]>;
  66421. };
  66422. /** @hidden */
  66423. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  66424. }
  66425. }
  66426. declare module BABYLON {
  66427. /**
  66428. * A class serves as a medium between the observable and its observers
  66429. */
  66430. export class EventState {
  66431. /**
  66432. * Create a new EventState
  66433. * @param mask defines the mask associated with this state
  66434. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66435. * @param target defines the original target of the state
  66436. * @param currentTarget defines the current target of the state
  66437. */
  66438. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66439. /**
  66440. * Initialize the current event state
  66441. * @param mask defines the mask associated with this state
  66442. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66443. * @param target defines the original target of the state
  66444. * @param currentTarget defines the current target of the state
  66445. * @returns the current event state
  66446. */
  66447. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66448. /**
  66449. * An Observer can set this property to true to prevent subsequent observers of being notified
  66450. */
  66451. skipNextObservers: boolean;
  66452. /**
  66453. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66454. */
  66455. mask: number;
  66456. /**
  66457. * The object that originally notified the event
  66458. */
  66459. target?: any;
  66460. /**
  66461. * The current object in the bubbling phase
  66462. */
  66463. currentTarget?: any;
  66464. /**
  66465. * This will be populated with the return value of the last function that was executed.
  66466. * If it is the first function in the callback chain it will be the event data.
  66467. */
  66468. lastReturnValue?: any;
  66469. }
  66470. /**
  66471. * Represent an Observer registered to a given Observable object.
  66472. */
  66473. export class Observer<T> {
  66474. /**
  66475. * Defines the callback to call when the observer is notified
  66476. */
  66477. callback: (eventData: T, eventState: EventState) => void;
  66478. /**
  66479. * Defines the mask of the observer (used to filter notifications)
  66480. */
  66481. mask: number;
  66482. /**
  66483. * Defines the current scope used to restore the JS context
  66484. */
  66485. scope: any;
  66486. /** @hidden */
  66487. _willBeUnregistered: boolean;
  66488. /**
  66489. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66490. */
  66491. unregisterOnNextCall: boolean;
  66492. /**
  66493. * Creates a new observer
  66494. * @param callback defines the callback to call when the observer is notified
  66495. * @param mask defines the mask of the observer (used to filter notifications)
  66496. * @param scope defines the current scope used to restore the JS context
  66497. */
  66498. constructor(
  66499. /**
  66500. * Defines the callback to call when the observer is notified
  66501. */
  66502. callback: (eventData: T, eventState: EventState) => void,
  66503. /**
  66504. * Defines the mask of the observer (used to filter notifications)
  66505. */
  66506. mask: number,
  66507. /**
  66508. * Defines the current scope used to restore the JS context
  66509. */
  66510. scope?: any);
  66511. }
  66512. /**
  66513. * Represent a list of observers registered to multiple Observables object.
  66514. */
  66515. export class MultiObserver<T> {
  66516. private _observers;
  66517. private _observables;
  66518. /**
  66519. * Release associated resources
  66520. */
  66521. dispose(): void;
  66522. /**
  66523. * Raise a callback when one of the observable will notify
  66524. * @param observables defines a list of observables to watch
  66525. * @param callback defines the callback to call on notification
  66526. * @param mask defines the mask used to filter notifications
  66527. * @param scope defines the current scope used to restore the JS context
  66528. * @returns the new MultiObserver
  66529. */
  66530. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66531. }
  66532. /**
  66533. * The Observable class is a simple implementation of the Observable pattern.
  66534. *
  66535. * 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.
  66536. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66537. * 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).
  66538. * 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.
  66539. */
  66540. export class Observable<T> {
  66541. private _observers;
  66542. private _eventState;
  66543. private _onObserverAdded;
  66544. /**
  66545. * Gets the list of observers
  66546. */
  66547. readonly observers: Array<Observer<T>>;
  66548. /**
  66549. * Creates a new observable
  66550. * @param onObserverAdded defines a callback to call when a new observer is added
  66551. */
  66552. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66553. /**
  66554. * Create a new Observer with the specified callback
  66555. * @param callback the callback that will be executed for that Observer
  66556. * @param mask the mask used to filter observers
  66557. * @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.
  66558. * @param scope optional scope for the callback to be called from
  66559. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66560. * @returns the new observer created for the callback
  66561. */
  66562. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66563. /**
  66564. * Create a new Observer with the specified callback and unregisters after the next notification
  66565. * @param callback the callback that will be executed for that Observer
  66566. * @returns the new observer created for the callback
  66567. */
  66568. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66569. /**
  66570. * Remove an Observer from the Observable object
  66571. * @param observer the instance of the Observer to remove
  66572. * @returns false if it doesn't belong to this Observable
  66573. */
  66574. remove(observer: Nullable<Observer<T>>): boolean;
  66575. /**
  66576. * Remove a callback from the Observable object
  66577. * @param callback the callback to remove
  66578. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66579. * @returns false if it doesn't belong to this Observable
  66580. */
  66581. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66582. private _deferUnregister;
  66583. private _remove;
  66584. /**
  66585. * Moves the observable to the top of the observer list making it get called first when notified
  66586. * @param observer the observer to move
  66587. */
  66588. makeObserverTopPriority(observer: Observer<T>): void;
  66589. /**
  66590. * Moves the observable to the bottom of the observer list making it get called last when notified
  66591. * @param observer the observer to move
  66592. */
  66593. makeObserverBottomPriority(observer: Observer<T>): void;
  66594. /**
  66595. * Notify all Observers by calling their respective callback with the given data
  66596. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66597. * @param eventData defines the data to send to all observers
  66598. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66599. * @param target defines the original target of the state
  66600. * @param currentTarget defines the current target of the state
  66601. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66602. */
  66603. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66604. /**
  66605. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66606. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66607. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66608. * and it is crucial that all callbacks will be executed.
  66609. * The order of the callbacks is kept, callbacks are not executed parallel.
  66610. *
  66611. * @param eventData The data to be sent to each callback
  66612. * @param mask is used to filter observers defaults to -1
  66613. * @param target defines the callback target (see EventState)
  66614. * @param currentTarget defines he current object in the bubbling phase
  66615. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66616. */
  66617. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66618. /**
  66619. * Notify a specific observer
  66620. * @param observer defines the observer to notify
  66621. * @param eventData defines the data to be sent to each callback
  66622. * @param mask is used to filter observers defaults to -1
  66623. */
  66624. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66625. /**
  66626. * Gets a boolean indicating if the observable has at least one observer
  66627. * @returns true is the Observable has at least one Observer registered
  66628. */
  66629. hasObservers(): boolean;
  66630. /**
  66631. * Clear the list of observers
  66632. */
  66633. clear(): void;
  66634. /**
  66635. * Clone the current observable
  66636. * @returns a new observable
  66637. */
  66638. clone(): Observable<T>;
  66639. /**
  66640. * Does this observable handles observer registered with a given mask
  66641. * @param mask defines the mask to be tested
  66642. * @return whether or not one observer registered with the given mask is handeled
  66643. **/
  66644. hasSpecificMask(mask?: number): boolean;
  66645. }
  66646. }
  66647. declare module BABYLON {
  66648. /**
  66649. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  66650. * Babylon.js
  66651. */
  66652. export class DomManagement {
  66653. /**
  66654. * Checks if the window object exists
  66655. * @returns true if the window object exists
  66656. */
  66657. static IsWindowObjectExist(): boolean;
  66658. /**
  66659. * Checks if the navigator object exists
  66660. * @returns true if the navigator object exists
  66661. */
  66662. static IsNavigatorAvailable(): boolean;
  66663. /**
  66664. * Extracts text content from a DOM element hierarchy
  66665. * @param element defines the root element
  66666. * @returns a string
  66667. */
  66668. static GetDOMTextContent(element: HTMLElement): string;
  66669. }
  66670. }
  66671. declare module BABYLON {
  66672. /**
  66673. * Logger used througouht the application to allow configuration of
  66674. * the log level required for the messages.
  66675. */
  66676. export class Logger {
  66677. /**
  66678. * No log
  66679. */
  66680. static readonly NoneLogLevel: number;
  66681. /**
  66682. * Only message logs
  66683. */
  66684. static readonly MessageLogLevel: number;
  66685. /**
  66686. * Only warning logs
  66687. */
  66688. static readonly WarningLogLevel: number;
  66689. /**
  66690. * Only error logs
  66691. */
  66692. static readonly ErrorLogLevel: number;
  66693. /**
  66694. * All logs
  66695. */
  66696. static readonly AllLogLevel: number;
  66697. private static _LogCache;
  66698. /**
  66699. * Gets a value indicating the number of loading errors
  66700. * @ignorenaming
  66701. */
  66702. static errorsCount: number;
  66703. /**
  66704. * Callback called when a new log is added
  66705. */
  66706. static OnNewCacheEntry: (entry: string) => void;
  66707. private static _AddLogEntry;
  66708. private static _FormatMessage;
  66709. private static _LogDisabled;
  66710. private static _LogEnabled;
  66711. private static _WarnDisabled;
  66712. private static _WarnEnabled;
  66713. private static _ErrorDisabled;
  66714. private static _ErrorEnabled;
  66715. /**
  66716. * Log a message to the console
  66717. */
  66718. static Log: (message: string) => void;
  66719. /**
  66720. * Write a warning message to the console
  66721. */
  66722. static Warn: (message: string) => void;
  66723. /**
  66724. * Write an error message to the console
  66725. */
  66726. static Error: (message: string) => void;
  66727. /**
  66728. * Gets current log cache (list of logs)
  66729. */
  66730. static readonly LogCache: string;
  66731. /**
  66732. * Clears the log cache
  66733. */
  66734. static ClearLogCache(): void;
  66735. /**
  66736. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  66737. */
  66738. static LogLevels: number;
  66739. }
  66740. }
  66741. declare module BABYLON {
  66742. /** @hidden */
  66743. export class _TypeStore {
  66744. /** @hidden */
  66745. static RegisteredTypes: {
  66746. [key: string]: Object;
  66747. };
  66748. /** @hidden */
  66749. static GetClass(fqdn: string): any;
  66750. }
  66751. }
  66752. declare module BABYLON {
  66753. /**
  66754. * Class containing a set of static utilities functions for deep copy.
  66755. */
  66756. export class DeepCopier {
  66757. /**
  66758. * Tries to copy an object by duplicating every property
  66759. * @param source defines the source object
  66760. * @param destination defines the target object
  66761. * @param doNotCopyList defines a list of properties to avoid
  66762. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  66763. */
  66764. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  66765. }
  66766. }
  66767. declare module BABYLON {
  66768. /**
  66769. * Class containing a set of static utilities functions for precision date
  66770. */
  66771. export class PrecisionDate {
  66772. /**
  66773. * Gets either window.performance.now() if supported or Date.now() else
  66774. */
  66775. static readonly Now: number;
  66776. }
  66777. }
  66778. declare module BABYLON {
  66779. /** @hidden */
  66780. export class _DevTools {
  66781. static WarnImport(name: string): string;
  66782. }
  66783. }
  66784. declare module BABYLON {
  66785. /**
  66786. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  66787. */
  66788. export class WebRequest {
  66789. private _xhr;
  66790. /**
  66791. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  66792. * i.e. when loading files, where the server/service expects an Authorization header
  66793. */
  66794. static CustomRequestHeaders: {
  66795. [key: string]: string;
  66796. };
  66797. /**
  66798. * Add callback functions in this array to update all the requests before they get sent to the network
  66799. */
  66800. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  66801. private _injectCustomRequestHeaders;
  66802. /**
  66803. * Gets or sets a function to be called when loading progress changes
  66804. */
  66805. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  66806. /**
  66807. * Returns client's state
  66808. */
  66809. readonly readyState: number;
  66810. /**
  66811. * Returns client's status
  66812. */
  66813. readonly status: number;
  66814. /**
  66815. * Returns client's status as a text
  66816. */
  66817. readonly statusText: string;
  66818. /**
  66819. * Returns client's response
  66820. */
  66821. readonly response: any;
  66822. /**
  66823. * Returns client's response url
  66824. */
  66825. readonly responseURL: string;
  66826. /**
  66827. * Returns client's response as text
  66828. */
  66829. readonly responseText: string;
  66830. /**
  66831. * Gets or sets the expected response type
  66832. */
  66833. responseType: XMLHttpRequestResponseType;
  66834. /** @hidden */
  66835. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  66836. /** @hidden */
  66837. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  66838. /**
  66839. * Cancels any network activity
  66840. */
  66841. abort(): void;
  66842. /**
  66843. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  66844. * @param body defines an optional request body
  66845. */
  66846. send(body?: Document | BodyInit | null): void;
  66847. /**
  66848. * Sets the request method, request URL
  66849. * @param method defines the method to use (GET, POST, etc..)
  66850. * @param url defines the url to connect with
  66851. */
  66852. open(method: string, url: string): void;
  66853. }
  66854. }
  66855. declare module BABYLON {
  66856. /**
  66857. * File request interface
  66858. */
  66859. export interface IFileRequest {
  66860. /**
  66861. * Raised when the request is complete (success or error).
  66862. */
  66863. onCompleteObservable: Observable<IFileRequest>;
  66864. /**
  66865. * Aborts the request for a file.
  66866. */
  66867. abort: () => void;
  66868. }
  66869. }
  66870. declare module BABYLON {
  66871. /**
  66872. * Scalar computation library
  66873. */
  66874. export class Scalar {
  66875. /**
  66876. * Two pi constants convenient for computation.
  66877. */
  66878. static TwoPi: number;
  66879. /**
  66880. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66881. * @param a number
  66882. * @param b number
  66883. * @param epsilon (default = 1.401298E-45)
  66884. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66885. */
  66886. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  66887. /**
  66888. * Returns a string : the upper case translation of the number i to hexadecimal.
  66889. * @param i number
  66890. * @returns the upper case translation of the number i to hexadecimal.
  66891. */
  66892. static ToHex(i: number): string;
  66893. /**
  66894. * Returns -1 if value is negative and +1 is value is positive.
  66895. * @param value the value
  66896. * @returns the value itself if it's equal to zero.
  66897. */
  66898. static Sign(value: number): number;
  66899. /**
  66900. * Returns the value itself if it's between min and max.
  66901. * Returns min if the value is lower than min.
  66902. * Returns max if the value is greater than max.
  66903. * @param value the value to clmap
  66904. * @param min the min value to clamp to (default: 0)
  66905. * @param max the max value to clamp to (default: 1)
  66906. * @returns the clamped value
  66907. */
  66908. static Clamp(value: number, min?: number, max?: number): number;
  66909. /**
  66910. * the log2 of value.
  66911. * @param value the value to compute log2 of
  66912. * @returns the log2 of value.
  66913. */
  66914. static Log2(value: number): number;
  66915. /**
  66916. * Loops the value, so that it is never larger than length and never smaller than 0.
  66917. *
  66918. * This is similar to the modulo operator but it works with floating point numbers.
  66919. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  66920. * With t = 5 and length = 2.5, the result would be 0.0.
  66921. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  66922. * @param value the value
  66923. * @param length the length
  66924. * @returns the looped value
  66925. */
  66926. static Repeat(value: number, length: number): number;
  66927. /**
  66928. * Normalize the value between 0.0 and 1.0 using min and max values
  66929. * @param value value to normalize
  66930. * @param min max to normalize between
  66931. * @param max min to normalize between
  66932. * @returns the normalized value
  66933. */
  66934. static Normalize(value: number, min: number, max: number): number;
  66935. /**
  66936. * Denormalize the value from 0.0 and 1.0 using min and max values
  66937. * @param normalized value to denormalize
  66938. * @param min max to denormalize between
  66939. * @param max min to denormalize between
  66940. * @returns the denormalized value
  66941. */
  66942. static Denormalize(normalized: number, min: number, max: number): number;
  66943. /**
  66944. * Calculates the shortest difference between two given angles given in degrees.
  66945. * @param current current angle in degrees
  66946. * @param target target angle in degrees
  66947. * @returns the delta
  66948. */
  66949. static DeltaAngle(current: number, target: number): number;
  66950. /**
  66951. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  66952. * @param tx value
  66953. * @param length length
  66954. * @returns The returned value will move back and forth between 0 and length
  66955. */
  66956. static PingPong(tx: number, length: number): number;
  66957. /**
  66958. * Interpolates between min and max with smoothing at the limits.
  66959. *
  66960. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  66961. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  66962. * @param from from
  66963. * @param to to
  66964. * @param tx value
  66965. * @returns the smooth stepped value
  66966. */
  66967. static SmoothStep(from: number, to: number, tx: number): number;
  66968. /**
  66969. * Moves a value current towards target.
  66970. *
  66971. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  66972. * Negative values of maxDelta pushes the value away from target.
  66973. * @param current current value
  66974. * @param target target value
  66975. * @param maxDelta max distance to move
  66976. * @returns resulting value
  66977. */
  66978. static MoveTowards(current: number, target: number, maxDelta: number): number;
  66979. /**
  66980. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66981. *
  66982. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  66983. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  66984. * @param current current value
  66985. * @param target target value
  66986. * @param maxDelta max distance to move
  66987. * @returns resulting angle
  66988. */
  66989. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  66990. /**
  66991. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  66992. * @param start start value
  66993. * @param end target value
  66994. * @param amount amount to lerp between
  66995. * @returns the lerped value
  66996. */
  66997. static Lerp(start: number, end: number, amount: number): number;
  66998. /**
  66999. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67000. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  67001. * @param start start value
  67002. * @param end target value
  67003. * @param amount amount to lerp between
  67004. * @returns the lerped value
  67005. */
  67006. static LerpAngle(start: number, end: number, amount: number): number;
  67007. /**
  67008. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  67009. * @param a start value
  67010. * @param b target value
  67011. * @param value value between a and b
  67012. * @returns the inverseLerp value
  67013. */
  67014. static InverseLerp(a: number, b: number, value: number): number;
  67015. /**
  67016. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  67017. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  67018. * @param value1 spline value
  67019. * @param tangent1 spline value
  67020. * @param value2 spline value
  67021. * @param tangent2 spline value
  67022. * @param amount input value
  67023. * @returns hermite result
  67024. */
  67025. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  67026. /**
  67027. * Returns a random float number between and min and max values
  67028. * @param min min value of random
  67029. * @param max max value of random
  67030. * @returns random value
  67031. */
  67032. static RandomRange(min: number, max: number): number;
  67033. /**
  67034. * This function returns percentage of a number in a given range.
  67035. *
  67036. * RangeToPercent(40,20,60) will return 0.5 (50%)
  67037. * RangeToPercent(34,0,100) will return 0.34 (34%)
  67038. * @param number to convert to percentage
  67039. * @param min min range
  67040. * @param max max range
  67041. * @returns the percentage
  67042. */
  67043. static RangeToPercent(number: number, min: number, max: number): number;
  67044. /**
  67045. * This function returns number that corresponds to the percentage in a given range.
  67046. *
  67047. * PercentToRange(0.34,0,100) will return 34.
  67048. * @param percent to convert to number
  67049. * @param min min range
  67050. * @param max max range
  67051. * @returns the number
  67052. */
  67053. static PercentToRange(percent: number, min: number, max: number): number;
  67054. /**
  67055. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  67056. * @param angle The angle to normalize in radian.
  67057. * @return The converted angle.
  67058. */
  67059. static NormalizeRadians(angle: number): number;
  67060. }
  67061. }
  67062. declare module BABYLON {
  67063. /**
  67064. * Constant used to convert a value to gamma space
  67065. * @ignorenaming
  67066. */
  67067. export const ToGammaSpace: number;
  67068. /**
  67069. * Constant used to convert a value to linear space
  67070. * @ignorenaming
  67071. */
  67072. export const ToLinearSpace = 2.2;
  67073. /**
  67074. * Constant used to define the minimal number value in Babylon.js
  67075. * @ignorenaming
  67076. */
  67077. let Epsilon: number;
  67078. }
  67079. declare module BABYLON {
  67080. /**
  67081. * Class used to represent a viewport on screen
  67082. */
  67083. export class Viewport {
  67084. /** viewport left coordinate */
  67085. x: number;
  67086. /** viewport top coordinate */
  67087. y: number;
  67088. /**viewport width */
  67089. width: number;
  67090. /** viewport height */
  67091. height: number;
  67092. /**
  67093. * Creates a Viewport object located at (x, y) and sized (width, height)
  67094. * @param x defines viewport left coordinate
  67095. * @param y defines viewport top coordinate
  67096. * @param width defines the viewport width
  67097. * @param height defines the viewport height
  67098. */
  67099. constructor(
  67100. /** viewport left coordinate */
  67101. x: number,
  67102. /** viewport top coordinate */
  67103. y: number,
  67104. /**viewport width */
  67105. width: number,
  67106. /** viewport height */
  67107. height: number);
  67108. /**
  67109. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  67110. * @param renderWidth defines the rendering width
  67111. * @param renderHeight defines the rendering height
  67112. * @returns a new Viewport
  67113. */
  67114. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  67115. /**
  67116. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  67117. * @param renderWidth defines the rendering width
  67118. * @param renderHeight defines the rendering height
  67119. * @param ref defines the target viewport
  67120. * @returns the current viewport
  67121. */
  67122. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  67123. /**
  67124. * Returns a new Viewport copied from the current one
  67125. * @returns a new Viewport
  67126. */
  67127. clone(): Viewport;
  67128. }
  67129. }
  67130. declare module BABYLON {
  67131. /**
  67132. * Class containing a set of static utilities functions for arrays.
  67133. */
  67134. export class ArrayTools {
  67135. /**
  67136. * Returns an array of the given size filled with element built from the given constructor and the paramters
  67137. * @param size the number of element to construct and put in the array
  67138. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  67139. * @returns a new array filled with new objects
  67140. */
  67141. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  67142. }
  67143. }
  67144. declare module BABYLON {
  67145. /**
  67146. * @hidden
  67147. */
  67148. export interface IColor4Like {
  67149. r: float;
  67150. g: float;
  67151. b: float;
  67152. a: float;
  67153. }
  67154. /**
  67155. * @hidden
  67156. */
  67157. export interface IColor3Like {
  67158. r: float;
  67159. g: float;
  67160. b: float;
  67161. }
  67162. /**
  67163. * @hidden
  67164. */
  67165. export interface IVector4Like {
  67166. x: float;
  67167. y: float;
  67168. z: float;
  67169. w: float;
  67170. }
  67171. /**
  67172. * @hidden
  67173. */
  67174. export interface IVector3Like {
  67175. x: float;
  67176. y: float;
  67177. z: float;
  67178. }
  67179. /**
  67180. * @hidden
  67181. */
  67182. export interface IVector2Like {
  67183. x: float;
  67184. y: float;
  67185. }
  67186. /**
  67187. * @hidden
  67188. */
  67189. export interface IMatrixLike {
  67190. toArray(): DeepImmutable<Float32Array>;
  67191. updateFlag: int;
  67192. }
  67193. /**
  67194. * @hidden
  67195. */
  67196. export interface IViewportLike {
  67197. x: float;
  67198. y: float;
  67199. width: float;
  67200. height: float;
  67201. }
  67202. /**
  67203. * @hidden
  67204. */
  67205. export interface IPlaneLike {
  67206. normal: IVector3Like;
  67207. d: float;
  67208. normalize(): void;
  67209. }
  67210. }
  67211. declare module BABYLON {
  67212. /**
  67213. * Class representing a vector containing 2 coordinates
  67214. */
  67215. export class Vector2 {
  67216. /** defines the first coordinate */
  67217. x: number;
  67218. /** defines the second coordinate */
  67219. y: number;
  67220. /**
  67221. * Creates a new Vector2 from the given x and y coordinates
  67222. * @param x defines the first coordinate
  67223. * @param y defines the second coordinate
  67224. */
  67225. constructor(
  67226. /** defines the first coordinate */
  67227. x?: number,
  67228. /** defines the second coordinate */
  67229. y?: number);
  67230. /**
  67231. * Gets a string with the Vector2 coordinates
  67232. * @returns a string with the Vector2 coordinates
  67233. */
  67234. toString(): string;
  67235. /**
  67236. * Gets class name
  67237. * @returns the string "Vector2"
  67238. */
  67239. getClassName(): string;
  67240. /**
  67241. * Gets current vector hash code
  67242. * @returns the Vector2 hash code as a number
  67243. */
  67244. getHashCode(): number;
  67245. /**
  67246. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  67247. * @param array defines the source array
  67248. * @param index defines the offset in source array
  67249. * @returns the current Vector2
  67250. */
  67251. toArray(array: FloatArray, index?: number): Vector2;
  67252. /**
  67253. * Copy the current vector to an array
  67254. * @returns a new array with 2 elements: the Vector2 coordinates.
  67255. */
  67256. asArray(): number[];
  67257. /**
  67258. * Sets the Vector2 coordinates with the given Vector2 coordinates
  67259. * @param source defines the source Vector2
  67260. * @returns the current updated Vector2
  67261. */
  67262. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  67263. /**
  67264. * Sets the Vector2 coordinates with the given floats
  67265. * @param x defines the first coordinate
  67266. * @param y defines the second coordinate
  67267. * @returns the current updated Vector2
  67268. */
  67269. copyFromFloats(x: number, y: number): Vector2;
  67270. /**
  67271. * Sets the Vector2 coordinates with the given floats
  67272. * @param x defines the first coordinate
  67273. * @param y defines the second coordinate
  67274. * @returns the current updated Vector2
  67275. */
  67276. set(x: number, y: number): Vector2;
  67277. /**
  67278. * Add another vector with the current one
  67279. * @param otherVector defines the other vector
  67280. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  67281. */
  67282. add(otherVector: DeepImmutable<Vector2>): Vector2;
  67283. /**
  67284. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  67285. * @param otherVector defines the other vector
  67286. * @param result defines the target vector
  67287. * @returns the unmodified current Vector2
  67288. */
  67289. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67290. /**
  67291. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  67292. * @param otherVector defines the other vector
  67293. * @returns the current updated Vector2
  67294. */
  67295. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67296. /**
  67297. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  67298. * @param otherVector defines the other vector
  67299. * @returns a new Vector2
  67300. */
  67301. addVector3(otherVector: Vector3): Vector2;
  67302. /**
  67303. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  67304. * @param otherVector defines the other vector
  67305. * @returns a new Vector2
  67306. */
  67307. subtract(otherVector: Vector2): Vector2;
  67308. /**
  67309. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  67310. * @param otherVector defines the other vector
  67311. * @param result defines the target vector
  67312. * @returns the unmodified current Vector2
  67313. */
  67314. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67315. /**
  67316. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  67317. * @param otherVector defines the other vector
  67318. * @returns the current updated Vector2
  67319. */
  67320. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67321. /**
  67322. * Multiplies in place the current Vector2 coordinates by the given ones
  67323. * @param otherVector defines the other vector
  67324. * @returns the current updated Vector2
  67325. */
  67326. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67327. /**
  67328. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  67329. * @param otherVector defines the other vector
  67330. * @returns a new Vector2
  67331. */
  67332. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  67333. /**
  67334. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  67335. * @param otherVector defines the other vector
  67336. * @param result defines the target vector
  67337. * @returns the unmodified current Vector2
  67338. */
  67339. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67340. /**
  67341. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  67342. * @param x defines the first coordinate
  67343. * @param y defines the second coordinate
  67344. * @returns a new Vector2
  67345. */
  67346. multiplyByFloats(x: number, y: number): Vector2;
  67347. /**
  67348. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  67349. * @param otherVector defines the other vector
  67350. * @returns a new Vector2
  67351. */
  67352. divide(otherVector: Vector2): Vector2;
  67353. /**
  67354. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67355. * @param otherVector defines the other vector
  67356. * @param result defines the target vector
  67357. * @returns the unmodified current Vector2
  67358. */
  67359. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67360. /**
  67361. * Divides the current Vector2 coordinates by the given ones
  67362. * @param otherVector defines the other vector
  67363. * @returns the current updated Vector2
  67364. */
  67365. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67366. /**
  67367. * Gets a new Vector2 with current Vector2 negated coordinates
  67368. * @returns a new Vector2
  67369. */
  67370. negate(): Vector2;
  67371. /**
  67372. * Multiply the Vector2 coordinates by scale
  67373. * @param scale defines the scaling factor
  67374. * @returns the current updated Vector2
  67375. */
  67376. scaleInPlace(scale: number): Vector2;
  67377. /**
  67378. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67379. * @param scale defines the scaling factor
  67380. * @returns a new Vector2
  67381. */
  67382. scale(scale: number): Vector2;
  67383. /**
  67384. * Scale the current Vector2 values by a factor to a given Vector2
  67385. * @param scale defines the scale factor
  67386. * @param result defines the Vector2 object where to store the result
  67387. * @returns the unmodified current Vector2
  67388. */
  67389. scaleToRef(scale: number, result: Vector2): Vector2;
  67390. /**
  67391. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67392. * @param scale defines the scale factor
  67393. * @param result defines the Vector2 object where to store the result
  67394. * @returns the unmodified current Vector2
  67395. */
  67396. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  67397. /**
  67398. * Gets a boolean if two vectors are equals
  67399. * @param otherVector defines the other vector
  67400. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67401. */
  67402. equals(otherVector: DeepImmutable<Vector2>): boolean;
  67403. /**
  67404. * Gets a boolean if two vectors are equals (using an epsilon value)
  67405. * @param otherVector defines the other vector
  67406. * @param epsilon defines the minimal distance to consider equality
  67407. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67408. */
  67409. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  67410. /**
  67411. * Gets a new Vector2 from current Vector2 floored values
  67412. * @returns a new Vector2
  67413. */
  67414. floor(): Vector2;
  67415. /**
  67416. * Gets a new Vector2 from current Vector2 floored values
  67417. * @returns a new Vector2
  67418. */
  67419. fract(): Vector2;
  67420. /**
  67421. * Gets the length of the vector
  67422. * @returns the vector length (float)
  67423. */
  67424. length(): number;
  67425. /**
  67426. * Gets the vector squared length
  67427. * @returns the vector squared length (float)
  67428. */
  67429. lengthSquared(): number;
  67430. /**
  67431. * Normalize the vector
  67432. * @returns the current updated Vector2
  67433. */
  67434. normalize(): Vector2;
  67435. /**
  67436. * Gets a new Vector2 copied from the Vector2
  67437. * @returns a new Vector2
  67438. */
  67439. clone(): Vector2;
  67440. /**
  67441. * Gets a new Vector2(0, 0)
  67442. * @returns a new Vector2
  67443. */
  67444. static Zero(): Vector2;
  67445. /**
  67446. * Gets a new Vector2(1, 1)
  67447. * @returns a new Vector2
  67448. */
  67449. static One(): Vector2;
  67450. /**
  67451. * Gets a new Vector2 set from the given index element of the given array
  67452. * @param array defines the data source
  67453. * @param offset defines the offset in the data source
  67454. * @returns a new Vector2
  67455. */
  67456. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  67457. /**
  67458. * Sets "result" from the given index element of the given array
  67459. * @param array defines the data source
  67460. * @param offset defines the offset in the data source
  67461. * @param result defines the target vector
  67462. */
  67463. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  67464. /**
  67465. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  67466. * @param value1 defines 1st point of control
  67467. * @param value2 defines 2nd point of control
  67468. * @param value3 defines 3rd point of control
  67469. * @param value4 defines 4th point of control
  67470. * @param amount defines the interpolation factor
  67471. * @returns a new Vector2
  67472. */
  67473. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  67474. /**
  67475. * 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".
  67476. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  67477. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  67478. * @param value defines the value to clamp
  67479. * @param min defines the lower limit
  67480. * @param max defines the upper limit
  67481. * @returns a new Vector2
  67482. */
  67483. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  67484. /**
  67485. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  67486. * @param value1 defines the 1st control point
  67487. * @param tangent1 defines the outgoing tangent
  67488. * @param value2 defines the 2nd control point
  67489. * @param tangent2 defines the incoming tangent
  67490. * @param amount defines the interpolation factor
  67491. * @returns a new Vector2
  67492. */
  67493. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  67494. /**
  67495. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  67496. * @param start defines the start vector
  67497. * @param end defines the end vector
  67498. * @param amount defines the interpolation factor
  67499. * @returns a new Vector2
  67500. */
  67501. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  67502. /**
  67503. * Gets the dot product of the vector "left" and the vector "right"
  67504. * @param left defines first vector
  67505. * @param right defines second vector
  67506. * @returns the dot product (float)
  67507. */
  67508. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  67509. /**
  67510. * Returns a new Vector2 equal to the normalized given vector
  67511. * @param vector defines the vector to normalize
  67512. * @returns a new Vector2
  67513. */
  67514. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  67515. /**
  67516. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  67517. * @param left defines 1st vector
  67518. * @param right defines 2nd vector
  67519. * @returns a new Vector2
  67520. */
  67521. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67522. /**
  67523. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  67524. * @param left defines 1st vector
  67525. * @param right defines 2nd vector
  67526. * @returns a new Vector2
  67527. */
  67528. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67529. /**
  67530. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  67531. * @param vector defines the vector to transform
  67532. * @param transformation defines the matrix to apply
  67533. * @returns a new Vector2
  67534. */
  67535. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  67536. /**
  67537. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  67538. * @param vector defines the vector to transform
  67539. * @param transformation defines the matrix to apply
  67540. * @param result defines the target vector
  67541. */
  67542. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  67543. /**
  67544. * Determines if a given vector is included in a triangle
  67545. * @param p defines the vector to test
  67546. * @param p0 defines 1st triangle point
  67547. * @param p1 defines 2nd triangle point
  67548. * @param p2 defines 3rd triangle point
  67549. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  67550. */
  67551. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  67552. /**
  67553. * Gets the distance between the vectors "value1" and "value2"
  67554. * @param value1 defines first vector
  67555. * @param value2 defines second vector
  67556. * @returns the distance between vectors
  67557. */
  67558. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67559. /**
  67560. * Returns the squared distance between the vectors "value1" and "value2"
  67561. * @param value1 defines first vector
  67562. * @param value2 defines second vector
  67563. * @returns the squared distance between vectors
  67564. */
  67565. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67566. /**
  67567. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  67568. * @param value1 defines first vector
  67569. * @param value2 defines second vector
  67570. * @returns a new Vector2
  67571. */
  67572. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  67573. /**
  67574. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  67575. * @param p defines the middle point
  67576. * @param segA defines one point of the segment
  67577. * @param segB defines the other point of the segment
  67578. * @returns the shortest distance
  67579. */
  67580. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  67581. }
  67582. /**
  67583. * Classed used to store (x,y,z) vector representation
  67584. * A Vector3 is the main object used in 3D geometry
  67585. * It can represent etiher the coordinates of a point the space, either a direction
  67586. * Reminder: js uses a left handed forward facing system
  67587. */
  67588. export class Vector3 {
  67589. /**
  67590. * Defines the first coordinates (on X axis)
  67591. */
  67592. x: number;
  67593. /**
  67594. * Defines the second coordinates (on Y axis)
  67595. */
  67596. y: number;
  67597. /**
  67598. * Defines the third coordinates (on Z axis)
  67599. */
  67600. z: number;
  67601. private static _UpReadOnly;
  67602. private static _ZeroReadOnly;
  67603. /**
  67604. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  67605. * @param x defines the first coordinates (on X axis)
  67606. * @param y defines the second coordinates (on Y axis)
  67607. * @param z defines the third coordinates (on Z axis)
  67608. */
  67609. constructor(
  67610. /**
  67611. * Defines the first coordinates (on X axis)
  67612. */
  67613. x?: number,
  67614. /**
  67615. * Defines the second coordinates (on Y axis)
  67616. */
  67617. y?: number,
  67618. /**
  67619. * Defines the third coordinates (on Z axis)
  67620. */
  67621. z?: number);
  67622. /**
  67623. * Creates a string representation of the Vector3
  67624. * @returns a string with the Vector3 coordinates.
  67625. */
  67626. toString(): string;
  67627. /**
  67628. * Gets the class name
  67629. * @returns the string "Vector3"
  67630. */
  67631. getClassName(): string;
  67632. /**
  67633. * Creates the Vector3 hash code
  67634. * @returns a number which tends to be unique between Vector3 instances
  67635. */
  67636. getHashCode(): number;
  67637. /**
  67638. * Creates an array containing three elements : the coordinates of the Vector3
  67639. * @returns a new array of numbers
  67640. */
  67641. asArray(): number[];
  67642. /**
  67643. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  67644. * @param array defines the destination array
  67645. * @param index defines the offset in the destination array
  67646. * @returns the current Vector3
  67647. */
  67648. toArray(array: FloatArray, index?: number): Vector3;
  67649. /**
  67650. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  67651. * @returns a new Quaternion object, computed from the Vector3 coordinates
  67652. */
  67653. toQuaternion(): Quaternion;
  67654. /**
  67655. * Adds the given vector to the current Vector3
  67656. * @param otherVector defines the second operand
  67657. * @returns the current updated Vector3
  67658. */
  67659. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67660. /**
  67661. * Adds the given coordinates to the current Vector3
  67662. * @param x defines the x coordinate of the operand
  67663. * @param y defines the y coordinate of the operand
  67664. * @param z defines the z coordinate of the operand
  67665. * @returns the current updated Vector3
  67666. */
  67667. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67668. /**
  67669. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  67670. * @param otherVector defines the second operand
  67671. * @returns the resulting Vector3
  67672. */
  67673. add(otherVector: DeepImmutable<Vector3>): Vector3;
  67674. /**
  67675. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  67676. * @param otherVector defines the second operand
  67677. * @param result defines the Vector3 object where to store the result
  67678. * @returns the current Vector3
  67679. */
  67680. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67681. /**
  67682. * Subtract the given vector from the current Vector3
  67683. * @param otherVector defines the second operand
  67684. * @returns the current updated Vector3
  67685. */
  67686. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67687. /**
  67688. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  67689. * @param otherVector defines the second operand
  67690. * @returns the resulting Vector3
  67691. */
  67692. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  67693. /**
  67694. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  67695. * @param otherVector defines the second operand
  67696. * @param result defines the Vector3 object where to store the result
  67697. * @returns the current Vector3
  67698. */
  67699. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67700. /**
  67701. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  67702. * @param x defines the x coordinate of the operand
  67703. * @param y defines the y coordinate of the operand
  67704. * @param z defines the z coordinate of the operand
  67705. * @returns the resulting Vector3
  67706. */
  67707. subtractFromFloats(x: number, y: number, z: number): Vector3;
  67708. /**
  67709. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  67710. * @param x defines the x coordinate of the operand
  67711. * @param y defines the y coordinate of the operand
  67712. * @param z defines the z coordinate of the operand
  67713. * @param result defines the Vector3 object where to store the result
  67714. * @returns the current Vector3
  67715. */
  67716. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  67717. /**
  67718. * Gets a new Vector3 set with the current Vector3 negated coordinates
  67719. * @returns a new Vector3
  67720. */
  67721. negate(): Vector3;
  67722. /**
  67723. * Multiplies the Vector3 coordinates by the float "scale"
  67724. * @param scale defines the multiplier factor
  67725. * @returns the current updated Vector3
  67726. */
  67727. scaleInPlace(scale: number): Vector3;
  67728. /**
  67729. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  67730. * @param scale defines the multiplier factor
  67731. * @returns a new Vector3
  67732. */
  67733. scale(scale: number): Vector3;
  67734. /**
  67735. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  67736. * @param scale defines the multiplier factor
  67737. * @param result defines the Vector3 object where to store the result
  67738. * @returns the current Vector3
  67739. */
  67740. scaleToRef(scale: number, result: Vector3): Vector3;
  67741. /**
  67742. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  67743. * @param scale defines the scale factor
  67744. * @param result defines the Vector3 object where to store the result
  67745. * @returns the unmodified current Vector3
  67746. */
  67747. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  67748. /**
  67749. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  67750. * @param otherVector defines the second operand
  67751. * @returns true if both vectors are equals
  67752. */
  67753. equals(otherVector: DeepImmutable<Vector3>): boolean;
  67754. /**
  67755. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  67756. * @param otherVector defines the second operand
  67757. * @param epsilon defines the minimal distance to define values as equals
  67758. * @returns true if both vectors are distant less than epsilon
  67759. */
  67760. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  67761. /**
  67762. * Returns true if the current Vector3 coordinates equals the given floats
  67763. * @param x defines the x coordinate of the operand
  67764. * @param y defines the y coordinate of the operand
  67765. * @param z defines the z coordinate of the operand
  67766. * @returns true if both vectors are equals
  67767. */
  67768. equalsToFloats(x: number, y: number, z: number): boolean;
  67769. /**
  67770. * Multiplies the current Vector3 coordinates by the given ones
  67771. * @param otherVector defines the second operand
  67772. * @returns the current updated Vector3
  67773. */
  67774. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67775. /**
  67776. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  67777. * @param otherVector defines the second operand
  67778. * @returns the new Vector3
  67779. */
  67780. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  67781. /**
  67782. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  67783. * @param otherVector defines the second operand
  67784. * @param result defines the Vector3 object where to store the result
  67785. * @returns the current Vector3
  67786. */
  67787. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67788. /**
  67789. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  67790. * @param x defines the x coordinate of the operand
  67791. * @param y defines the y coordinate of the operand
  67792. * @param z defines the z coordinate of the operand
  67793. * @returns the new Vector3
  67794. */
  67795. multiplyByFloats(x: number, y: number, z: number): Vector3;
  67796. /**
  67797. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  67798. * @param otherVector defines the second operand
  67799. * @returns the new Vector3
  67800. */
  67801. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  67802. /**
  67803. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  67804. * @param otherVector defines the second operand
  67805. * @param result defines the Vector3 object where to store the result
  67806. * @returns the current Vector3
  67807. */
  67808. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67809. /**
  67810. * Divides the current Vector3 coordinates by the given ones.
  67811. * @param otherVector defines the second operand
  67812. * @returns the current updated Vector3
  67813. */
  67814. divideInPlace(otherVector: Vector3): Vector3;
  67815. /**
  67816. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  67817. * @param other defines the second operand
  67818. * @returns the current updated Vector3
  67819. */
  67820. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67821. /**
  67822. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  67823. * @param other defines the second operand
  67824. * @returns the current updated Vector3
  67825. */
  67826. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67827. /**
  67828. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  67829. * @param x defines the x coordinate of the operand
  67830. * @param y defines the y coordinate of the operand
  67831. * @param z defines the z coordinate of the operand
  67832. * @returns the current updated Vector3
  67833. */
  67834. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67835. /**
  67836. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  67837. * @param x defines the x coordinate of the operand
  67838. * @param y defines the y coordinate of the operand
  67839. * @param z defines the z coordinate of the operand
  67840. * @returns the current updated Vector3
  67841. */
  67842. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67843. /**
  67844. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  67845. * Check if is non uniform within a certain amount of decimal places to account for this
  67846. * @param epsilon the amount the values can differ
  67847. * @returns if the the vector is non uniform to a certain number of decimal places
  67848. */
  67849. isNonUniformWithinEpsilon(epsilon: number): boolean;
  67850. /**
  67851. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  67852. */
  67853. readonly isNonUniform: boolean;
  67854. /**
  67855. * Gets a new Vector3 from current Vector3 floored values
  67856. * @returns a new Vector3
  67857. */
  67858. floor(): Vector3;
  67859. /**
  67860. * Gets a new Vector3 from current Vector3 floored values
  67861. * @returns a new Vector3
  67862. */
  67863. fract(): Vector3;
  67864. /**
  67865. * Gets the length of the Vector3
  67866. * @returns the length of the Vector3
  67867. */
  67868. length(): number;
  67869. /**
  67870. * Gets the squared length of the Vector3
  67871. * @returns squared length of the Vector3
  67872. */
  67873. lengthSquared(): number;
  67874. /**
  67875. * Normalize the current Vector3.
  67876. * Please note that this is an in place operation.
  67877. * @returns the current updated Vector3
  67878. */
  67879. normalize(): Vector3;
  67880. /**
  67881. * Reorders the x y z properties of the vector in place
  67882. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  67883. * @returns the current updated vector
  67884. */
  67885. reorderInPlace(order: string): this;
  67886. /**
  67887. * Rotates the vector around 0,0,0 by a quaternion
  67888. * @param quaternion the rotation quaternion
  67889. * @param result vector to store the result
  67890. * @returns the resulting vector
  67891. */
  67892. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  67893. /**
  67894. * Rotates a vector around a given point
  67895. * @param quaternion the rotation quaternion
  67896. * @param point the point to rotate around
  67897. * @param result vector to store the result
  67898. * @returns the resulting vector
  67899. */
  67900. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  67901. /**
  67902. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  67903. * The cross product is then orthogonal to both current and "other"
  67904. * @param other defines the right operand
  67905. * @returns the cross product
  67906. */
  67907. cross(other: Vector3): Vector3;
  67908. /**
  67909. * Normalize the current Vector3 with the given input length.
  67910. * Please note that this is an in place operation.
  67911. * @param len the length of the vector
  67912. * @returns the current updated Vector3
  67913. */
  67914. normalizeFromLength(len: number): Vector3;
  67915. /**
  67916. * Normalize the current Vector3 to a new vector
  67917. * @returns the new Vector3
  67918. */
  67919. normalizeToNew(): Vector3;
  67920. /**
  67921. * Normalize the current Vector3 to the reference
  67922. * @param reference define the Vector3 to update
  67923. * @returns the updated Vector3
  67924. */
  67925. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  67926. /**
  67927. * Creates a new Vector3 copied from the current Vector3
  67928. * @returns the new Vector3
  67929. */
  67930. clone(): Vector3;
  67931. /**
  67932. * Copies the given vector coordinates to the current Vector3 ones
  67933. * @param source defines the source Vector3
  67934. * @returns the current updated Vector3
  67935. */
  67936. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  67937. /**
  67938. * Copies the given floats to the current Vector3 coordinates
  67939. * @param x defines the x coordinate of the operand
  67940. * @param y defines the y coordinate of the operand
  67941. * @param z defines the z coordinate of the operand
  67942. * @returns the current updated Vector3
  67943. */
  67944. copyFromFloats(x: number, y: number, z: number): Vector3;
  67945. /**
  67946. * Copies the given floats to the current Vector3 coordinates
  67947. * @param x defines the x coordinate of the operand
  67948. * @param y defines the y coordinate of the operand
  67949. * @param z defines the z coordinate of the operand
  67950. * @returns the current updated Vector3
  67951. */
  67952. set(x: number, y: number, z: number): Vector3;
  67953. /**
  67954. * Copies the given float to the current Vector3 coordinates
  67955. * @param v defines the x, y and z coordinates of the operand
  67956. * @returns the current updated Vector3
  67957. */
  67958. setAll(v: number): Vector3;
  67959. /**
  67960. * Get the clip factor between two vectors
  67961. * @param vector0 defines the first operand
  67962. * @param vector1 defines the second operand
  67963. * @param axis defines the axis to use
  67964. * @param size defines the size along the axis
  67965. * @returns the clip factor
  67966. */
  67967. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  67968. /**
  67969. * Get angle between two vectors
  67970. * @param vector0 angle between vector0 and vector1
  67971. * @param vector1 angle between vector0 and vector1
  67972. * @param normal direction of the normal
  67973. * @return the angle between vector0 and vector1
  67974. */
  67975. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  67976. /**
  67977. * Returns a new Vector3 set from the index "offset" of the given array
  67978. * @param array defines the source array
  67979. * @param offset defines the offset in the source array
  67980. * @returns the new Vector3
  67981. */
  67982. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  67983. /**
  67984. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  67985. * This function is deprecated. Use FromArray instead
  67986. * @param array defines the source array
  67987. * @param offset defines the offset in the source array
  67988. * @returns the new Vector3
  67989. */
  67990. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  67991. /**
  67992. * Sets the given vector "result" with the element values from the index "offset" of the given array
  67993. * @param array defines the source array
  67994. * @param offset defines the offset in the source array
  67995. * @param result defines the Vector3 where to store the result
  67996. */
  67997. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  67998. /**
  67999. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  68000. * This function is deprecated. Use FromArrayToRef instead.
  68001. * @param array defines the source array
  68002. * @param offset defines the offset in the source array
  68003. * @param result defines the Vector3 where to store the result
  68004. */
  68005. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  68006. /**
  68007. * Sets the given vector "result" with the given floats.
  68008. * @param x defines the x coordinate of the source
  68009. * @param y defines the y coordinate of the source
  68010. * @param z defines the z coordinate of the source
  68011. * @param result defines the Vector3 where to store the result
  68012. */
  68013. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  68014. /**
  68015. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  68016. * @returns a new empty Vector3
  68017. */
  68018. static Zero(): Vector3;
  68019. /**
  68020. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  68021. * @returns a new unit Vector3
  68022. */
  68023. static One(): Vector3;
  68024. /**
  68025. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  68026. * @returns a new up Vector3
  68027. */
  68028. static Up(): Vector3;
  68029. /**
  68030. * Gets a up Vector3 that must not be updated
  68031. */
  68032. static readonly UpReadOnly: DeepImmutable<Vector3>;
  68033. /**
  68034. * Gets a zero Vector3 that must not be updated
  68035. */
  68036. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  68037. /**
  68038. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  68039. * @returns a new down Vector3
  68040. */
  68041. static Down(): Vector3;
  68042. /**
  68043. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  68044. * @returns a new forward Vector3
  68045. */
  68046. static Forward(): Vector3;
  68047. /**
  68048. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  68049. * @returns a new forward Vector3
  68050. */
  68051. static Backward(): Vector3;
  68052. /**
  68053. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  68054. * @returns a new right Vector3
  68055. */
  68056. static Right(): Vector3;
  68057. /**
  68058. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  68059. * @returns a new left Vector3
  68060. */
  68061. static Left(): Vector3;
  68062. /**
  68063. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  68064. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68065. * @param vector defines the Vector3 to transform
  68066. * @param transformation defines the transformation matrix
  68067. * @returns the transformed Vector3
  68068. */
  68069. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68070. /**
  68071. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  68072. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68073. * @param vector defines the Vector3 to transform
  68074. * @param transformation defines the transformation matrix
  68075. * @param result defines the Vector3 where to store the result
  68076. */
  68077. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68078. /**
  68079. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  68080. * This method computes tranformed coordinates only, not transformed direction vectors
  68081. * @param x define the x coordinate of the source vector
  68082. * @param y define the y coordinate of the source vector
  68083. * @param z define the z coordinate of the source vector
  68084. * @param transformation defines the transformation matrix
  68085. * @param result defines the Vector3 where to store the result
  68086. */
  68087. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68088. /**
  68089. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  68090. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68091. * @param vector defines the Vector3 to transform
  68092. * @param transformation defines the transformation matrix
  68093. * @returns the new Vector3
  68094. */
  68095. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68096. /**
  68097. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  68098. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68099. * @param vector defines the Vector3 to transform
  68100. * @param transformation defines the transformation matrix
  68101. * @param result defines the Vector3 where to store the result
  68102. */
  68103. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68104. /**
  68105. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  68106. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68107. * @param x define the x coordinate of the source vector
  68108. * @param y define the y coordinate of the source vector
  68109. * @param z define the z coordinate of the source vector
  68110. * @param transformation defines the transformation matrix
  68111. * @param result defines the Vector3 where to store the result
  68112. */
  68113. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68114. /**
  68115. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  68116. * @param value1 defines the first control point
  68117. * @param value2 defines the second control point
  68118. * @param value3 defines the third control point
  68119. * @param value4 defines the fourth control point
  68120. * @param amount defines the amount on the spline to use
  68121. * @returns the new Vector3
  68122. */
  68123. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  68124. /**
  68125. * 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"
  68126. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68127. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68128. * @param value defines the current value
  68129. * @param min defines the lower range value
  68130. * @param max defines the upper range value
  68131. * @returns the new Vector3
  68132. */
  68133. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  68134. /**
  68135. * 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"
  68136. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68137. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68138. * @param value defines the current value
  68139. * @param min defines the lower range value
  68140. * @param max defines the upper range value
  68141. * @param result defines the Vector3 where to store the result
  68142. */
  68143. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  68144. /**
  68145. * Checks if a given vector is inside a specific range
  68146. * @param v defines the vector to test
  68147. * @param min defines the minimum range
  68148. * @param max defines the maximum range
  68149. */
  68150. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  68151. /**
  68152. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  68153. * @param value1 defines the first control point
  68154. * @param tangent1 defines the first tangent vector
  68155. * @param value2 defines the second control point
  68156. * @param tangent2 defines the second tangent vector
  68157. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  68158. * @returns the new Vector3
  68159. */
  68160. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  68161. /**
  68162. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  68163. * @param start defines the start value
  68164. * @param end defines the end value
  68165. * @param amount max defines amount between both (between 0 and 1)
  68166. * @returns the new Vector3
  68167. */
  68168. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  68169. /**
  68170. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  68171. * @param start defines the start value
  68172. * @param end defines the end value
  68173. * @param amount max defines amount between both (between 0 and 1)
  68174. * @param result defines the Vector3 where to store the result
  68175. */
  68176. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  68177. /**
  68178. * Returns the dot product (float) between the vectors "left" and "right"
  68179. * @param left defines the left operand
  68180. * @param right defines the right operand
  68181. * @returns the dot product
  68182. */
  68183. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  68184. /**
  68185. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  68186. * The cross product is then orthogonal to both "left" and "right"
  68187. * @param left defines the left operand
  68188. * @param right defines the right operand
  68189. * @returns the cross product
  68190. */
  68191. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68192. /**
  68193. * Sets the given vector "result" with the cross product of "left" and "right"
  68194. * The cross product is then orthogonal to both "left" and "right"
  68195. * @param left defines the left operand
  68196. * @param right defines the right operand
  68197. * @param result defines the Vector3 where to store the result
  68198. */
  68199. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  68200. /**
  68201. * Returns a new Vector3 as the normalization of the given vector
  68202. * @param vector defines the Vector3 to normalize
  68203. * @returns the new Vector3
  68204. */
  68205. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  68206. /**
  68207. * Sets the given vector "result" with the normalization of the given first vector
  68208. * @param vector defines the Vector3 to normalize
  68209. * @param result defines the Vector3 where to store the result
  68210. */
  68211. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  68212. /**
  68213. * Project a Vector3 onto screen space
  68214. * @param vector defines the Vector3 to project
  68215. * @param world defines the world matrix to use
  68216. * @param transform defines the transform (view x projection) matrix to use
  68217. * @param viewport defines the screen viewport to use
  68218. * @returns the new Vector3
  68219. */
  68220. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  68221. /** @hidden */
  68222. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  68223. /**
  68224. * Unproject from screen space to object space
  68225. * @param source defines the screen space Vector3 to use
  68226. * @param viewportWidth defines the current width of the viewport
  68227. * @param viewportHeight defines the current height of the viewport
  68228. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68229. * @param transform defines the transform (view x projection) matrix to use
  68230. * @returns the new Vector3
  68231. */
  68232. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  68233. /**
  68234. * Unproject from screen space to object space
  68235. * @param source defines the screen space Vector3 to use
  68236. * @param viewportWidth defines the current width of the viewport
  68237. * @param viewportHeight defines the current height of the viewport
  68238. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68239. * @param view defines the view matrix to use
  68240. * @param projection defines the projection matrix to use
  68241. * @returns the new Vector3
  68242. */
  68243. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  68244. /**
  68245. * Unproject from screen space to object space
  68246. * @param source defines the screen space Vector3 to use
  68247. * @param viewportWidth defines the current width of the viewport
  68248. * @param viewportHeight defines the current height of the viewport
  68249. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68250. * @param view defines the view matrix to use
  68251. * @param projection defines the projection matrix to use
  68252. * @param result defines the Vector3 where to store the result
  68253. */
  68254. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68255. /**
  68256. * Unproject from screen space to object space
  68257. * @param sourceX defines the screen space x coordinate to use
  68258. * @param sourceY defines the screen space y coordinate to use
  68259. * @param sourceZ defines the screen space z coordinate to use
  68260. * @param viewportWidth defines the current width of the viewport
  68261. * @param viewportHeight defines the current height of the viewport
  68262. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68263. * @param view defines the view matrix to use
  68264. * @param projection defines the projection matrix to use
  68265. * @param result defines the Vector3 where to store the result
  68266. */
  68267. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68268. /**
  68269. * Gets the minimal coordinate values between two Vector3
  68270. * @param left defines the first operand
  68271. * @param right defines the second operand
  68272. * @returns the new Vector3
  68273. */
  68274. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68275. /**
  68276. * Gets the maximal coordinate values between two Vector3
  68277. * @param left defines the first operand
  68278. * @param right defines the second operand
  68279. * @returns the new Vector3
  68280. */
  68281. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68282. /**
  68283. * Returns the distance between the vectors "value1" and "value2"
  68284. * @param value1 defines the first operand
  68285. * @param value2 defines the second operand
  68286. * @returns the distance
  68287. */
  68288. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68289. /**
  68290. * Returns the squared distance between the vectors "value1" and "value2"
  68291. * @param value1 defines the first operand
  68292. * @param value2 defines the second operand
  68293. * @returns the squared distance
  68294. */
  68295. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68296. /**
  68297. * Returns a new Vector3 located at the center between "value1" and "value2"
  68298. * @param value1 defines the first operand
  68299. * @param value2 defines the second operand
  68300. * @returns the new Vector3
  68301. */
  68302. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  68303. /**
  68304. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  68305. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  68306. * to something in order to rotate it from its local system to the given target system
  68307. * Note: axis1, axis2 and axis3 are normalized during this operation
  68308. * @param axis1 defines the first axis
  68309. * @param axis2 defines the second axis
  68310. * @param axis3 defines the third axis
  68311. * @returns a new Vector3
  68312. */
  68313. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  68314. /**
  68315. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  68316. * @param axis1 defines the first axis
  68317. * @param axis2 defines the second axis
  68318. * @param axis3 defines the third axis
  68319. * @param ref defines the Vector3 where to store the result
  68320. */
  68321. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  68322. }
  68323. /**
  68324. * Vector4 class created for EulerAngle class conversion to Quaternion
  68325. */
  68326. export class Vector4 {
  68327. /** x value of the vector */
  68328. x: number;
  68329. /** y value of the vector */
  68330. y: number;
  68331. /** z value of the vector */
  68332. z: number;
  68333. /** w value of the vector */
  68334. w: number;
  68335. /**
  68336. * Creates a Vector4 object from the given floats.
  68337. * @param x x value of the vector
  68338. * @param y y value of the vector
  68339. * @param z z value of the vector
  68340. * @param w w value of the vector
  68341. */
  68342. constructor(
  68343. /** x value of the vector */
  68344. x: number,
  68345. /** y value of the vector */
  68346. y: number,
  68347. /** z value of the vector */
  68348. z: number,
  68349. /** w value of the vector */
  68350. w: number);
  68351. /**
  68352. * Returns the string with the Vector4 coordinates.
  68353. * @returns a string containing all the vector values
  68354. */
  68355. toString(): string;
  68356. /**
  68357. * Returns the string "Vector4".
  68358. * @returns "Vector4"
  68359. */
  68360. getClassName(): string;
  68361. /**
  68362. * Returns the Vector4 hash code.
  68363. * @returns a unique hash code
  68364. */
  68365. getHashCode(): number;
  68366. /**
  68367. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  68368. * @returns the resulting array
  68369. */
  68370. asArray(): number[];
  68371. /**
  68372. * Populates the given array from the given index with the Vector4 coordinates.
  68373. * @param array array to populate
  68374. * @param index index of the array to start at (default: 0)
  68375. * @returns the Vector4.
  68376. */
  68377. toArray(array: FloatArray, index?: number): Vector4;
  68378. /**
  68379. * Adds the given vector to the current Vector4.
  68380. * @param otherVector the vector to add
  68381. * @returns the updated Vector4.
  68382. */
  68383. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68384. /**
  68385. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  68386. * @param otherVector the vector to add
  68387. * @returns the resulting vector
  68388. */
  68389. add(otherVector: DeepImmutable<Vector4>): Vector4;
  68390. /**
  68391. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  68392. * @param otherVector the vector to add
  68393. * @param result the vector to store the result
  68394. * @returns the current Vector4.
  68395. */
  68396. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68397. /**
  68398. * Subtract in place the given vector from the current Vector4.
  68399. * @param otherVector the vector to subtract
  68400. * @returns the updated Vector4.
  68401. */
  68402. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68403. /**
  68404. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  68405. * @param otherVector the vector to add
  68406. * @returns the new vector with the result
  68407. */
  68408. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  68409. /**
  68410. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  68411. * @param otherVector the vector to subtract
  68412. * @param result the vector to store the result
  68413. * @returns the current Vector4.
  68414. */
  68415. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68416. /**
  68417. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68418. */
  68419. /**
  68420. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68421. * @param x value to subtract
  68422. * @param y value to subtract
  68423. * @param z value to subtract
  68424. * @param w value to subtract
  68425. * @returns new vector containing the result
  68426. */
  68427. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68428. /**
  68429. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68430. * @param x value to subtract
  68431. * @param y value to subtract
  68432. * @param z value to subtract
  68433. * @param w value to subtract
  68434. * @param result the vector to store the result in
  68435. * @returns the current Vector4.
  68436. */
  68437. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  68438. /**
  68439. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  68440. * @returns a new vector with the negated values
  68441. */
  68442. negate(): Vector4;
  68443. /**
  68444. * Multiplies the current Vector4 coordinates by scale (float).
  68445. * @param scale the number to scale with
  68446. * @returns the updated Vector4.
  68447. */
  68448. scaleInPlace(scale: number): Vector4;
  68449. /**
  68450. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  68451. * @param scale the number to scale with
  68452. * @returns a new vector with the result
  68453. */
  68454. scale(scale: number): Vector4;
  68455. /**
  68456. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  68457. * @param scale the number to scale with
  68458. * @param result a vector to store the result in
  68459. * @returns the current Vector4.
  68460. */
  68461. scaleToRef(scale: number, result: Vector4): Vector4;
  68462. /**
  68463. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  68464. * @param scale defines the scale factor
  68465. * @param result defines the Vector4 object where to store the result
  68466. * @returns the unmodified current Vector4
  68467. */
  68468. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  68469. /**
  68470. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  68471. * @param otherVector the vector to compare against
  68472. * @returns true if they are equal
  68473. */
  68474. equals(otherVector: DeepImmutable<Vector4>): boolean;
  68475. /**
  68476. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  68477. * @param otherVector vector to compare against
  68478. * @param epsilon (Default: very small number)
  68479. * @returns true if they are equal
  68480. */
  68481. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  68482. /**
  68483. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  68484. * @param x x value to compare against
  68485. * @param y y value to compare against
  68486. * @param z z value to compare against
  68487. * @param w w value to compare against
  68488. * @returns true if equal
  68489. */
  68490. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  68491. /**
  68492. * Multiplies in place the current Vector4 by the given one.
  68493. * @param otherVector vector to multiple with
  68494. * @returns the updated Vector4.
  68495. */
  68496. multiplyInPlace(otherVector: Vector4): Vector4;
  68497. /**
  68498. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  68499. * @param otherVector vector to multiple with
  68500. * @returns resulting new vector
  68501. */
  68502. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  68503. /**
  68504. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  68505. * @param otherVector vector to multiple with
  68506. * @param result vector to store the result
  68507. * @returns the current Vector4.
  68508. */
  68509. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68510. /**
  68511. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  68512. * @param x x value multiply with
  68513. * @param y y value multiply with
  68514. * @param z z value multiply with
  68515. * @param w w value multiply with
  68516. * @returns resulting new vector
  68517. */
  68518. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  68519. /**
  68520. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  68521. * @param otherVector vector to devide with
  68522. * @returns resulting new vector
  68523. */
  68524. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  68525. /**
  68526. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  68527. * @param otherVector vector to devide with
  68528. * @param result vector to store the result
  68529. * @returns the current Vector4.
  68530. */
  68531. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68532. /**
  68533. * Divides the current Vector3 coordinates by the given ones.
  68534. * @param otherVector vector to devide with
  68535. * @returns the updated Vector3.
  68536. */
  68537. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68538. /**
  68539. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  68540. * @param other defines the second operand
  68541. * @returns the current updated Vector4
  68542. */
  68543. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68544. /**
  68545. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  68546. * @param other defines the second operand
  68547. * @returns the current updated Vector4
  68548. */
  68549. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68550. /**
  68551. * Gets a new Vector4 from current Vector4 floored values
  68552. * @returns a new Vector4
  68553. */
  68554. floor(): Vector4;
  68555. /**
  68556. * Gets a new Vector4 from current Vector3 floored values
  68557. * @returns a new Vector4
  68558. */
  68559. fract(): Vector4;
  68560. /**
  68561. * Returns the Vector4 length (float).
  68562. * @returns the length
  68563. */
  68564. length(): number;
  68565. /**
  68566. * Returns the Vector4 squared length (float).
  68567. * @returns the length squared
  68568. */
  68569. lengthSquared(): number;
  68570. /**
  68571. * Normalizes in place the Vector4.
  68572. * @returns the updated Vector4.
  68573. */
  68574. normalize(): Vector4;
  68575. /**
  68576. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  68577. * @returns this converted to a new vector3
  68578. */
  68579. toVector3(): Vector3;
  68580. /**
  68581. * Returns a new Vector4 copied from the current one.
  68582. * @returns the new cloned vector
  68583. */
  68584. clone(): Vector4;
  68585. /**
  68586. * Updates the current Vector4 with the given one coordinates.
  68587. * @param source the source vector to copy from
  68588. * @returns the updated Vector4.
  68589. */
  68590. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  68591. /**
  68592. * Updates the current Vector4 coordinates with the given floats.
  68593. * @param x float to copy from
  68594. * @param y float to copy from
  68595. * @param z float to copy from
  68596. * @param w float to copy from
  68597. * @returns the updated Vector4.
  68598. */
  68599. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68600. /**
  68601. * Updates the current Vector4 coordinates with the given floats.
  68602. * @param x float to set from
  68603. * @param y float to set from
  68604. * @param z float to set from
  68605. * @param w float to set from
  68606. * @returns the updated Vector4.
  68607. */
  68608. set(x: number, y: number, z: number, w: number): Vector4;
  68609. /**
  68610. * Copies the given float to the current Vector3 coordinates
  68611. * @param v defines the x, y, z and w coordinates of the operand
  68612. * @returns the current updated Vector3
  68613. */
  68614. setAll(v: number): Vector4;
  68615. /**
  68616. * Returns a new Vector4 set from the starting index of the given array.
  68617. * @param array the array to pull values from
  68618. * @param offset the offset into the array to start at
  68619. * @returns the new vector
  68620. */
  68621. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  68622. /**
  68623. * Updates the given vector "result" from the starting index of the given array.
  68624. * @param array the array to pull values from
  68625. * @param offset the offset into the array to start at
  68626. * @param result the vector to store the result in
  68627. */
  68628. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  68629. /**
  68630. * Updates the given vector "result" from the starting index of the given Float32Array.
  68631. * @param array the array to pull values from
  68632. * @param offset the offset into the array to start at
  68633. * @param result the vector to store the result in
  68634. */
  68635. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  68636. /**
  68637. * Updates the given vector "result" coordinates from the given floats.
  68638. * @param x float to set from
  68639. * @param y float to set from
  68640. * @param z float to set from
  68641. * @param w float to set from
  68642. * @param result the vector to the floats in
  68643. */
  68644. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  68645. /**
  68646. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  68647. * @returns the new vector
  68648. */
  68649. static Zero(): Vector4;
  68650. /**
  68651. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  68652. * @returns the new vector
  68653. */
  68654. static One(): Vector4;
  68655. /**
  68656. * Returns a new normalized Vector4 from the given one.
  68657. * @param vector the vector to normalize
  68658. * @returns the vector
  68659. */
  68660. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  68661. /**
  68662. * Updates the given vector "result" from the normalization of the given one.
  68663. * @param vector the vector to normalize
  68664. * @param result the vector to store the result in
  68665. */
  68666. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  68667. /**
  68668. * Returns a vector with the minimum values from the left and right vectors
  68669. * @param left left vector to minimize
  68670. * @param right right vector to minimize
  68671. * @returns a new vector with the minimum of the left and right vector values
  68672. */
  68673. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68674. /**
  68675. * Returns a vector with the maximum values from the left and right vectors
  68676. * @param left left vector to maximize
  68677. * @param right right vector to maximize
  68678. * @returns a new vector with the maximum of the left and right vector values
  68679. */
  68680. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68681. /**
  68682. * Returns the distance (float) between the vectors "value1" and "value2".
  68683. * @param value1 value to calulate the distance between
  68684. * @param value2 value to calulate the distance between
  68685. * @return the distance between the two vectors
  68686. */
  68687. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68688. /**
  68689. * Returns the squared distance (float) between the vectors "value1" and "value2".
  68690. * @param value1 value to calulate the distance between
  68691. * @param value2 value to calulate the distance between
  68692. * @return the distance between the two vectors squared
  68693. */
  68694. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68695. /**
  68696. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  68697. * @param value1 value to calulate the center between
  68698. * @param value2 value to calulate the center between
  68699. * @return the center between the two vectors
  68700. */
  68701. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  68702. /**
  68703. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  68704. * This methods computes transformed normalized direction vectors only.
  68705. * @param vector the vector to transform
  68706. * @param transformation the transformation matrix to apply
  68707. * @returns the new vector
  68708. */
  68709. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  68710. /**
  68711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  68712. * This methods computes transformed normalized direction vectors only.
  68713. * @param vector the vector to transform
  68714. * @param transformation the transformation matrix to apply
  68715. * @param result the vector to store the result in
  68716. */
  68717. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68718. /**
  68719. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  68720. * This methods computes transformed normalized direction vectors only.
  68721. * @param x value to transform
  68722. * @param y value to transform
  68723. * @param z value to transform
  68724. * @param w value to transform
  68725. * @param transformation the transformation matrix to apply
  68726. * @param result the vector to store the results in
  68727. */
  68728. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68729. /**
  68730. * Creates a new Vector4 from a Vector3
  68731. * @param source defines the source data
  68732. * @param w defines the 4th component (default is 0)
  68733. * @returns a new Vector4
  68734. */
  68735. static FromVector3(source: Vector3, w?: number): Vector4;
  68736. }
  68737. /**
  68738. * Class used to store quaternion data
  68739. * @see https://en.wikipedia.org/wiki/Quaternion
  68740. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  68741. */
  68742. export class Quaternion {
  68743. /** defines the first component (0 by default) */
  68744. x: number;
  68745. /** defines the second component (0 by default) */
  68746. y: number;
  68747. /** defines the third component (0 by default) */
  68748. z: number;
  68749. /** defines the fourth component (1.0 by default) */
  68750. w: number;
  68751. /**
  68752. * Creates a new Quaternion from the given floats
  68753. * @param x defines the first component (0 by default)
  68754. * @param y defines the second component (0 by default)
  68755. * @param z defines the third component (0 by default)
  68756. * @param w defines the fourth component (1.0 by default)
  68757. */
  68758. constructor(
  68759. /** defines the first component (0 by default) */
  68760. x?: number,
  68761. /** defines the second component (0 by default) */
  68762. y?: number,
  68763. /** defines the third component (0 by default) */
  68764. z?: number,
  68765. /** defines the fourth component (1.0 by default) */
  68766. w?: number);
  68767. /**
  68768. * Gets a string representation for the current quaternion
  68769. * @returns a string with the Quaternion coordinates
  68770. */
  68771. toString(): string;
  68772. /**
  68773. * Gets the class name of the quaternion
  68774. * @returns the string "Quaternion"
  68775. */
  68776. getClassName(): string;
  68777. /**
  68778. * Gets a hash code for this quaternion
  68779. * @returns the quaternion hash code
  68780. */
  68781. getHashCode(): number;
  68782. /**
  68783. * Copy the quaternion to an array
  68784. * @returns a new array populated with 4 elements from the quaternion coordinates
  68785. */
  68786. asArray(): number[];
  68787. /**
  68788. * Check if two quaternions are equals
  68789. * @param otherQuaternion defines the second operand
  68790. * @return true if the current quaternion and the given one coordinates are strictly equals
  68791. */
  68792. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  68793. /**
  68794. * Clone the current quaternion
  68795. * @returns a new quaternion copied from the current one
  68796. */
  68797. clone(): Quaternion;
  68798. /**
  68799. * Copy a quaternion to the current one
  68800. * @param other defines the other quaternion
  68801. * @returns the updated current quaternion
  68802. */
  68803. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  68804. /**
  68805. * Updates the current quaternion with the given float coordinates
  68806. * @param x defines the x coordinate
  68807. * @param y defines the y coordinate
  68808. * @param z defines the z coordinate
  68809. * @param w defines the w coordinate
  68810. * @returns the updated current quaternion
  68811. */
  68812. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  68813. /**
  68814. * Updates the current quaternion from the given float coordinates
  68815. * @param x defines the x coordinate
  68816. * @param y defines the y coordinate
  68817. * @param z defines the z coordinate
  68818. * @param w defines the w coordinate
  68819. * @returns the updated current quaternion
  68820. */
  68821. set(x: number, y: number, z: number, w: number): Quaternion;
  68822. /**
  68823. * Adds two quaternions
  68824. * @param other defines the second operand
  68825. * @returns a new quaternion as the addition result of the given one and the current quaternion
  68826. */
  68827. add(other: DeepImmutable<Quaternion>): Quaternion;
  68828. /**
  68829. * Add a quaternion to the current one
  68830. * @param other defines the quaternion to add
  68831. * @returns the current quaternion
  68832. */
  68833. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  68834. /**
  68835. * Subtract two quaternions
  68836. * @param other defines the second operand
  68837. * @returns a new quaternion as the subtraction result of the given one from the current one
  68838. */
  68839. subtract(other: Quaternion): Quaternion;
  68840. /**
  68841. * Multiplies the current quaternion by a scale factor
  68842. * @param value defines the scale factor
  68843. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  68844. */
  68845. scale(value: number): Quaternion;
  68846. /**
  68847. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  68848. * @param scale defines the scale factor
  68849. * @param result defines the Quaternion object where to store the result
  68850. * @returns the unmodified current quaternion
  68851. */
  68852. scaleToRef(scale: number, result: Quaternion): Quaternion;
  68853. /**
  68854. * Multiplies in place the current quaternion by a scale factor
  68855. * @param value defines the scale factor
  68856. * @returns the current modified quaternion
  68857. */
  68858. scaleInPlace(value: number): Quaternion;
  68859. /**
  68860. * Scale the current quaternion values by a factor and add the result to a given quaternion
  68861. * @param scale defines the scale factor
  68862. * @param result defines the Quaternion object where to store the result
  68863. * @returns the unmodified current quaternion
  68864. */
  68865. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  68866. /**
  68867. * Multiplies two quaternions
  68868. * @param q1 defines the second operand
  68869. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  68870. */
  68871. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  68872. /**
  68873. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  68874. * @param q1 defines the second operand
  68875. * @param result defines the target quaternion
  68876. * @returns the current quaternion
  68877. */
  68878. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  68879. /**
  68880. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  68881. * @param q1 defines the second operand
  68882. * @returns the currentupdated quaternion
  68883. */
  68884. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  68885. /**
  68886. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  68887. * @param ref defines the target quaternion
  68888. * @returns the current quaternion
  68889. */
  68890. conjugateToRef(ref: Quaternion): Quaternion;
  68891. /**
  68892. * Conjugates in place (1-q) the current quaternion
  68893. * @returns the current updated quaternion
  68894. */
  68895. conjugateInPlace(): Quaternion;
  68896. /**
  68897. * Conjugates in place (1-q) the current quaternion
  68898. * @returns a new quaternion
  68899. */
  68900. conjugate(): Quaternion;
  68901. /**
  68902. * Gets length of current quaternion
  68903. * @returns the quaternion length (float)
  68904. */
  68905. length(): number;
  68906. /**
  68907. * Normalize in place the current quaternion
  68908. * @returns the current updated quaternion
  68909. */
  68910. normalize(): Quaternion;
  68911. /**
  68912. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  68913. * @param order is a reserved parameter and is ignore for now
  68914. * @returns a new Vector3 containing the Euler angles
  68915. */
  68916. toEulerAngles(order?: string): Vector3;
  68917. /**
  68918. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  68919. * @param result defines the vector which will be filled with the Euler angles
  68920. * @param order is a reserved parameter and is ignore for now
  68921. * @returns the current unchanged quaternion
  68922. */
  68923. toEulerAnglesToRef(result: Vector3): Quaternion;
  68924. /**
  68925. * Updates the given rotation matrix with the current quaternion values
  68926. * @param result defines the target matrix
  68927. * @returns the current unchanged quaternion
  68928. */
  68929. toRotationMatrix(result: Matrix): Quaternion;
  68930. /**
  68931. * Updates the current quaternion from the given rotation matrix values
  68932. * @param matrix defines the source matrix
  68933. * @returns the current updated quaternion
  68934. */
  68935. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68936. /**
  68937. * Creates a new quaternion from a rotation matrix
  68938. * @param matrix defines the source matrix
  68939. * @returns a new quaternion created from the given rotation matrix values
  68940. */
  68941. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68942. /**
  68943. * Updates the given quaternion with the given rotation matrix values
  68944. * @param matrix defines the source matrix
  68945. * @param result defines the target quaternion
  68946. */
  68947. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  68948. /**
  68949. * Returns the dot product (float) between the quaternions "left" and "right"
  68950. * @param left defines the left operand
  68951. * @param right defines the right operand
  68952. * @returns the dot product
  68953. */
  68954. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  68955. /**
  68956. * Checks if the two quaternions are close to each other
  68957. * @param quat0 defines the first quaternion to check
  68958. * @param quat1 defines the second quaternion to check
  68959. * @returns true if the two quaternions are close to each other
  68960. */
  68961. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  68962. /**
  68963. * Creates an empty quaternion
  68964. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  68965. */
  68966. static Zero(): Quaternion;
  68967. /**
  68968. * Inverse a given quaternion
  68969. * @param q defines the source quaternion
  68970. * @returns a new quaternion as the inverted current quaternion
  68971. */
  68972. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  68973. /**
  68974. * Inverse a given quaternion
  68975. * @param q defines the source quaternion
  68976. * @param result the quaternion the result will be stored in
  68977. * @returns the result quaternion
  68978. */
  68979. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  68980. /**
  68981. * Creates an identity quaternion
  68982. * @returns the identity quaternion
  68983. */
  68984. static Identity(): Quaternion;
  68985. /**
  68986. * Gets a boolean indicating if the given quaternion is identity
  68987. * @param quaternion defines the quaternion to check
  68988. * @returns true if the quaternion is identity
  68989. */
  68990. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  68991. /**
  68992. * Creates a quaternion from a rotation around an axis
  68993. * @param axis defines the axis to use
  68994. * @param angle defines the angle to use
  68995. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  68996. */
  68997. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  68998. /**
  68999. * Creates a rotation around an axis and stores it into the given quaternion
  69000. * @param axis defines the axis to use
  69001. * @param angle defines the angle to use
  69002. * @param result defines the target quaternion
  69003. * @returns the target quaternion
  69004. */
  69005. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  69006. /**
  69007. * Creates a new quaternion from data stored into an array
  69008. * @param array defines the data source
  69009. * @param offset defines the offset in the source array where the data starts
  69010. * @returns a new quaternion
  69011. */
  69012. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  69013. /**
  69014. * Create a quaternion from Euler rotation angles
  69015. * @param x Pitch
  69016. * @param y Yaw
  69017. * @param z Roll
  69018. * @returns the new Quaternion
  69019. */
  69020. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  69021. /**
  69022. * Updates a quaternion from Euler rotation angles
  69023. * @param x Pitch
  69024. * @param y Yaw
  69025. * @param z Roll
  69026. * @param result the quaternion to store the result
  69027. * @returns the updated quaternion
  69028. */
  69029. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  69030. /**
  69031. * Create a quaternion from Euler rotation vector
  69032. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69033. * @returns the new Quaternion
  69034. */
  69035. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  69036. /**
  69037. * Updates a quaternion from Euler rotation vector
  69038. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69039. * @param result the quaternion to store the result
  69040. * @returns the updated quaternion
  69041. */
  69042. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  69043. /**
  69044. * Creates a new quaternion from the given Euler float angles (y, x, z)
  69045. * @param yaw defines the rotation around Y axis
  69046. * @param pitch defines the rotation around X axis
  69047. * @param roll defines the rotation around Z axis
  69048. * @returns the new quaternion
  69049. */
  69050. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  69051. /**
  69052. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  69053. * @param yaw defines the rotation around Y axis
  69054. * @param pitch defines the rotation around X axis
  69055. * @param roll defines the rotation around Z axis
  69056. * @param result defines the target quaternion
  69057. */
  69058. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  69059. /**
  69060. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  69061. * @param alpha defines the rotation around first axis
  69062. * @param beta defines the rotation around second axis
  69063. * @param gamma defines the rotation around third axis
  69064. * @returns the new quaternion
  69065. */
  69066. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  69067. /**
  69068. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  69069. * @param alpha defines the rotation around first axis
  69070. * @param beta defines the rotation around second axis
  69071. * @param gamma defines the rotation around third axis
  69072. * @param result defines the target quaternion
  69073. */
  69074. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  69075. /**
  69076. * 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)
  69077. * @param axis1 defines the first axis
  69078. * @param axis2 defines the second axis
  69079. * @param axis3 defines the third axis
  69080. * @returns the new quaternion
  69081. */
  69082. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  69083. /**
  69084. * 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
  69085. * @param axis1 defines the first axis
  69086. * @param axis2 defines the second axis
  69087. * @param axis3 defines the third axis
  69088. * @param ref defines the target quaternion
  69089. */
  69090. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  69091. /**
  69092. * Interpolates between two quaternions
  69093. * @param left defines first quaternion
  69094. * @param right defines second quaternion
  69095. * @param amount defines the gradient to use
  69096. * @returns the new interpolated quaternion
  69097. */
  69098. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69099. /**
  69100. * Interpolates between two quaternions and stores it into a target quaternion
  69101. * @param left defines first quaternion
  69102. * @param right defines second quaternion
  69103. * @param amount defines the gradient to use
  69104. * @param result defines the target quaternion
  69105. */
  69106. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  69107. /**
  69108. * Interpolate between two quaternions using Hermite interpolation
  69109. * @param value1 defines first quaternion
  69110. * @param tangent1 defines the incoming tangent
  69111. * @param value2 defines second quaternion
  69112. * @param tangent2 defines the outgoing tangent
  69113. * @param amount defines the target quaternion
  69114. * @returns the new interpolated quaternion
  69115. */
  69116. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69117. }
  69118. /**
  69119. * Class used to store matrix data (4x4)
  69120. */
  69121. export class Matrix {
  69122. private static _updateFlagSeed;
  69123. private static _identityReadOnly;
  69124. private _isIdentity;
  69125. private _isIdentityDirty;
  69126. private _isIdentity3x2;
  69127. private _isIdentity3x2Dirty;
  69128. /**
  69129. * Gets the update flag of the matrix which is an unique number for the matrix.
  69130. * It will be incremented every time the matrix data change.
  69131. * You can use it to speed the comparison between two versions of the same matrix.
  69132. */
  69133. updateFlag: number;
  69134. private readonly _m;
  69135. /**
  69136. * Gets the internal data of the matrix
  69137. */
  69138. readonly m: DeepImmutable<Float32Array>;
  69139. /** @hidden */
  69140. _markAsUpdated(): void;
  69141. /** @hidden */
  69142. private _updateIdentityStatus;
  69143. /**
  69144. * Creates an empty matrix (filled with zeros)
  69145. */
  69146. constructor();
  69147. /**
  69148. * Check if the current matrix is identity
  69149. * @returns true is the matrix is the identity matrix
  69150. */
  69151. isIdentity(): boolean;
  69152. /**
  69153. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  69154. * @returns true is the matrix is the identity matrix
  69155. */
  69156. isIdentityAs3x2(): boolean;
  69157. /**
  69158. * Gets the determinant of the matrix
  69159. * @returns the matrix determinant
  69160. */
  69161. determinant(): number;
  69162. /**
  69163. * Returns the matrix as a Float32Array
  69164. * @returns the matrix underlying array
  69165. */
  69166. toArray(): DeepImmutable<Float32Array>;
  69167. /**
  69168. * Returns the matrix as a Float32Array
  69169. * @returns the matrix underlying array.
  69170. */
  69171. asArray(): DeepImmutable<Float32Array>;
  69172. /**
  69173. * Inverts the current matrix in place
  69174. * @returns the current inverted matrix
  69175. */
  69176. invert(): Matrix;
  69177. /**
  69178. * Sets all the matrix elements to zero
  69179. * @returns the current matrix
  69180. */
  69181. reset(): Matrix;
  69182. /**
  69183. * Adds the current matrix with a second one
  69184. * @param other defines the matrix to add
  69185. * @returns a new matrix as the addition of the current matrix and the given one
  69186. */
  69187. add(other: DeepImmutable<Matrix>): Matrix;
  69188. /**
  69189. * Sets the given matrix "result" to the addition of the current matrix and the given one
  69190. * @param other defines the matrix to add
  69191. * @param result defines the target matrix
  69192. * @returns the current matrix
  69193. */
  69194. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69195. /**
  69196. * Adds in place the given matrix to the current matrix
  69197. * @param other defines the second operand
  69198. * @returns the current updated matrix
  69199. */
  69200. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  69201. /**
  69202. * Sets the given matrix to the current inverted Matrix
  69203. * @param other defines the target matrix
  69204. * @returns the unmodified current matrix
  69205. */
  69206. invertToRef(other: Matrix): Matrix;
  69207. /**
  69208. * add a value at the specified position in the current Matrix
  69209. * @param index the index of the value within the matrix. between 0 and 15.
  69210. * @param value the value to be added
  69211. * @returns the current updated matrix
  69212. */
  69213. addAtIndex(index: number, value: number): Matrix;
  69214. /**
  69215. * mutiply the specified position in the current Matrix by a value
  69216. * @param index the index of the value within the matrix. between 0 and 15.
  69217. * @param value the value to be added
  69218. * @returns the current updated matrix
  69219. */
  69220. multiplyAtIndex(index: number, value: number): Matrix;
  69221. /**
  69222. * Inserts the translation vector (using 3 floats) in the current matrix
  69223. * @param x defines the 1st component of the translation
  69224. * @param y defines the 2nd component of the translation
  69225. * @param z defines the 3rd component of the translation
  69226. * @returns the current updated matrix
  69227. */
  69228. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69229. /**
  69230. * Adds the translation vector (using 3 floats) in the current matrix
  69231. * @param x defines the 1st component of the translation
  69232. * @param y defines the 2nd component of the translation
  69233. * @param z defines the 3rd component of the translation
  69234. * @returns the current updated matrix
  69235. */
  69236. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69237. /**
  69238. * Inserts the translation vector in the current matrix
  69239. * @param vector3 defines the translation to insert
  69240. * @returns the current updated matrix
  69241. */
  69242. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  69243. /**
  69244. * Gets the translation value of the current matrix
  69245. * @returns a new Vector3 as the extracted translation from the matrix
  69246. */
  69247. getTranslation(): Vector3;
  69248. /**
  69249. * Fill a Vector3 with the extracted translation from the matrix
  69250. * @param result defines the Vector3 where to store the translation
  69251. * @returns the current matrix
  69252. */
  69253. getTranslationToRef(result: Vector3): Matrix;
  69254. /**
  69255. * Remove rotation and scaling part from the matrix
  69256. * @returns the updated matrix
  69257. */
  69258. removeRotationAndScaling(): Matrix;
  69259. /**
  69260. * Multiply two matrices
  69261. * @param other defines the second operand
  69262. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  69263. */
  69264. multiply(other: DeepImmutable<Matrix>): Matrix;
  69265. /**
  69266. * Copy the current matrix from the given one
  69267. * @param other defines the source matrix
  69268. * @returns the current updated matrix
  69269. */
  69270. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  69271. /**
  69272. * Populates the given array from the starting index with the current matrix values
  69273. * @param array defines the target array
  69274. * @param offset defines the offset in the target array where to start storing values
  69275. * @returns the current matrix
  69276. */
  69277. copyToArray(array: Float32Array, offset?: number): Matrix;
  69278. /**
  69279. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  69280. * @param other defines the second operand
  69281. * @param result defines the matrix where to store the multiplication
  69282. * @returns the current matrix
  69283. */
  69284. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69285. /**
  69286. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  69287. * @param other defines the second operand
  69288. * @param result defines the array where to store the multiplication
  69289. * @param offset defines the offset in the target array where to start storing values
  69290. * @returns the current matrix
  69291. */
  69292. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  69293. /**
  69294. * Check equality between this matrix and a second one
  69295. * @param value defines the second matrix to compare
  69296. * @returns true is the current matrix and the given one values are strictly equal
  69297. */
  69298. equals(value: DeepImmutable<Matrix>): boolean;
  69299. /**
  69300. * Clone the current matrix
  69301. * @returns a new matrix from the current matrix
  69302. */
  69303. clone(): Matrix;
  69304. /**
  69305. * Returns the name of the current matrix class
  69306. * @returns the string "Matrix"
  69307. */
  69308. getClassName(): string;
  69309. /**
  69310. * Gets the hash code of the current matrix
  69311. * @returns the hash code
  69312. */
  69313. getHashCode(): number;
  69314. /**
  69315. * Decomposes the current Matrix into a translation, rotation and scaling components
  69316. * @param scale defines the scale vector3 given as a reference to update
  69317. * @param rotation defines the rotation quaternion given as a reference to update
  69318. * @param translation defines the translation vector3 given as a reference to update
  69319. * @returns true if operation was successful
  69320. */
  69321. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  69322. /**
  69323. * Gets specific row of the matrix
  69324. * @param index defines the number of the row to get
  69325. * @returns the index-th row of the current matrix as a new Vector4
  69326. */
  69327. getRow(index: number): Nullable<Vector4>;
  69328. /**
  69329. * Sets the index-th row of the current matrix to the vector4 values
  69330. * @param index defines the number of the row to set
  69331. * @param row defines the target vector4
  69332. * @returns the updated current matrix
  69333. */
  69334. setRow(index: number, row: Vector4): Matrix;
  69335. /**
  69336. * Compute the transpose of the matrix
  69337. * @returns the new transposed matrix
  69338. */
  69339. transpose(): Matrix;
  69340. /**
  69341. * Compute the transpose of the matrix and store it in a given matrix
  69342. * @param result defines the target matrix
  69343. * @returns the current matrix
  69344. */
  69345. transposeToRef(result: Matrix): Matrix;
  69346. /**
  69347. * Sets the index-th row of the current matrix with the given 4 x float values
  69348. * @param index defines the row index
  69349. * @param x defines the x component to set
  69350. * @param y defines the y component to set
  69351. * @param z defines the z component to set
  69352. * @param w defines the w component to set
  69353. * @returns the updated current matrix
  69354. */
  69355. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  69356. /**
  69357. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  69358. * @param scale defines the scale factor
  69359. * @returns a new matrix
  69360. */
  69361. scale(scale: number): Matrix;
  69362. /**
  69363. * Scale the current matrix values by a factor to a given result matrix
  69364. * @param scale defines the scale factor
  69365. * @param result defines the matrix to store the result
  69366. * @returns the current matrix
  69367. */
  69368. scaleToRef(scale: number, result: Matrix): Matrix;
  69369. /**
  69370. * Scale the current matrix values by a factor and add the result to a given matrix
  69371. * @param scale defines the scale factor
  69372. * @param result defines the Matrix to store the result
  69373. * @returns the current matrix
  69374. */
  69375. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  69376. /**
  69377. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  69378. * @param ref matrix to store the result
  69379. */
  69380. toNormalMatrix(ref: Matrix): void;
  69381. /**
  69382. * Gets only rotation part of the current matrix
  69383. * @returns a new matrix sets to the extracted rotation matrix from the current one
  69384. */
  69385. getRotationMatrix(): Matrix;
  69386. /**
  69387. * Extracts the rotation matrix from the current one and sets it as the given "result"
  69388. * @param result defines the target matrix to store data to
  69389. * @returns the current matrix
  69390. */
  69391. getRotationMatrixToRef(result: Matrix): Matrix;
  69392. /**
  69393. * Toggles model matrix from being right handed to left handed in place and vice versa
  69394. */
  69395. toggleModelMatrixHandInPlace(): void;
  69396. /**
  69397. * Toggles projection matrix from being right handed to left handed in place and vice versa
  69398. */
  69399. toggleProjectionMatrixHandInPlace(): void;
  69400. /**
  69401. * Creates a matrix from an array
  69402. * @param array defines the source array
  69403. * @param offset defines an offset in the source array
  69404. * @returns a new Matrix set from the starting index of the given array
  69405. */
  69406. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  69407. /**
  69408. * Copy the content of an array into a given matrix
  69409. * @param array defines the source array
  69410. * @param offset defines an offset in the source array
  69411. * @param result defines the target matrix
  69412. */
  69413. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  69414. /**
  69415. * Stores an array into a matrix after having multiplied each component by a given factor
  69416. * @param array defines the source array
  69417. * @param offset defines the offset in the source array
  69418. * @param scale defines the scaling factor
  69419. * @param result defines the target matrix
  69420. */
  69421. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  69422. /**
  69423. * Gets an identity matrix that must not be updated
  69424. */
  69425. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  69426. /**
  69427. * Stores a list of values (16) inside a given matrix
  69428. * @param initialM11 defines 1st value of 1st row
  69429. * @param initialM12 defines 2nd value of 1st row
  69430. * @param initialM13 defines 3rd value of 1st row
  69431. * @param initialM14 defines 4th value of 1st row
  69432. * @param initialM21 defines 1st value of 2nd row
  69433. * @param initialM22 defines 2nd value of 2nd row
  69434. * @param initialM23 defines 3rd value of 2nd row
  69435. * @param initialM24 defines 4th value of 2nd row
  69436. * @param initialM31 defines 1st value of 3rd row
  69437. * @param initialM32 defines 2nd value of 3rd row
  69438. * @param initialM33 defines 3rd value of 3rd row
  69439. * @param initialM34 defines 4th value of 3rd row
  69440. * @param initialM41 defines 1st value of 4th row
  69441. * @param initialM42 defines 2nd value of 4th row
  69442. * @param initialM43 defines 3rd value of 4th row
  69443. * @param initialM44 defines 4th value of 4th row
  69444. * @param result defines the target matrix
  69445. */
  69446. 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;
  69447. /**
  69448. * Creates new matrix from a list of values (16)
  69449. * @param initialM11 defines 1st value of 1st row
  69450. * @param initialM12 defines 2nd value of 1st row
  69451. * @param initialM13 defines 3rd value of 1st row
  69452. * @param initialM14 defines 4th value of 1st row
  69453. * @param initialM21 defines 1st value of 2nd row
  69454. * @param initialM22 defines 2nd value of 2nd row
  69455. * @param initialM23 defines 3rd value of 2nd row
  69456. * @param initialM24 defines 4th value of 2nd row
  69457. * @param initialM31 defines 1st value of 3rd row
  69458. * @param initialM32 defines 2nd value of 3rd row
  69459. * @param initialM33 defines 3rd value of 3rd row
  69460. * @param initialM34 defines 4th value of 3rd row
  69461. * @param initialM41 defines 1st value of 4th row
  69462. * @param initialM42 defines 2nd value of 4th row
  69463. * @param initialM43 defines 3rd value of 4th row
  69464. * @param initialM44 defines 4th value of 4th row
  69465. * @returns the new matrix
  69466. */
  69467. 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;
  69468. /**
  69469. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69470. * @param scale defines the scale vector3
  69471. * @param rotation defines the rotation quaternion
  69472. * @param translation defines the translation vector3
  69473. * @returns a new matrix
  69474. */
  69475. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  69476. /**
  69477. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69478. * @param scale defines the scale vector3
  69479. * @param rotation defines the rotation quaternion
  69480. * @param translation defines the translation vector3
  69481. * @param result defines the target matrix
  69482. */
  69483. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  69484. /**
  69485. * Creates a new identity matrix
  69486. * @returns a new identity matrix
  69487. */
  69488. static Identity(): Matrix;
  69489. /**
  69490. * Creates a new identity matrix and stores the result in a given matrix
  69491. * @param result defines the target matrix
  69492. */
  69493. static IdentityToRef(result: Matrix): void;
  69494. /**
  69495. * Creates a new zero matrix
  69496. * @returns a new zero matrix
  69497. */
  69498. static Zero(): Matrix;
  69499. /**
  69500. * Creates a new rotation matrix for "angle" radians around the X axis
  69501. * @param angle defines the angle (in radians) to use
  69502. * @return the new matrix
  69503. */
  69504. static RotationX(angle: number): Matrix;
  69505. /**
  69506. * Creates a new matrix as the invert of a given matrix
  69507. * @param source defines the source matrix
  69508. * @returns the new matrix
  69509. */
  69510. static Invert(source: DeepImmutable<Matrix>): Matrix;
  69511. /**
  69512. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  69513. * @param angle defines the angle (in radians) to use
  69514. * @param result defines the target matrix
  69515. */
  69516. static RotationXToRef(angle: number, result: Matrix): void;
  69517. /**
  69518. * Creates a new rotation matrix for "angle" radians around the Y axis
  69519. * @param angle defines the angle (in radians) to use
  69520. * @return the new matrix
  69521. */
  69522. static RotationY(angle: number): Matrix;
  69523. /**
  69524. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  69525. * @param angle defines the angle (in radians) to use
  69526. * @param result defines the target matrix
  69527. */
  69528. static RotationYToRef(angle: number, result: Matrix): void;
  69529. /**
  69530. * Creates a new rotation matrix for "angle" radians around the Z axis
  69531. * @param angle defines the angle (in radians) to use
  69532. * @return the new matrix
  69533. */
  69534. static RotationZ(angle: number): Matrix;
  69535. /**
  69536. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  69537. * @param angle defines the angle (in radians) to use
  69538. * @param result defines the target matrix
  69539. */
  69540. static RotationZToRef(angle: number, result: Matrix): void;
  69541. /**
  69542. * Creates a new rotation matrix for "angle" radians around the given axis
  69543. * @param axis defines the axis to use
  69544. * @param angle defines the angle (in radians) to use
  69545. * @return the new matrix
  69546. */
  69547. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  69548. /**
  69549. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  69550. * @param axis defines the axis to use
  69551. * @param angle defines the angle (in radians) to use
  69552. * @param result defines the target matrix
  69553. */
  69554. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  69555. /**
  69556. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  69557. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  69558. * @param from defines the vector to align
  69559. * @param to defines the vector to align to
  69560. * @param result defines the target matrix
  69561. */
  69562. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  69563. /**
  69564. * Creates a rotation matrix
  69565. * @param yaw defines the yaw angle in radians (Y axis)
  69566. * @param pitch defines the pitch angle in radians (X axis)
  69567. * @param roll defines the roll angle in radians (X axis)
  69568. * @returns the new rotation matrix
  69569. */
  69570. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  69571. /**
  69572. * Creates a rotation matrix and stores it in a given matrix
  69573. * @param yaw defines the yaw angle in radians (Y axis)
  69574. * @param pitch defines the pitch angle in radians (X axis)
  69575. * @param roll defines the roll angle in radians (X axis)
  69576. * @param result defines the target matrix
  69577. */
  69578. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  69579. /**
  69580. * Creates a scaling matrix
  69581. * @param x defines the scale factor on X axis
  69582. * @param y defines the scale factor on Y axis
  69583. * @param z defines the scale factor on Z axis
  69584. * @returns the new matrix
  69585. */
  69586. static Scaling(x: number, y: number, z: number): Matrix;
  69587. /**
  69588. * Creates a scaling matrix and stores it in a given matrix
  69589. * @param x defines the scale factor on X axis
  69590. * @param y defines the scale factor on Y axis
  69591. * @param z defines the scale factor on Z axis
  69592. * @param result defines the target matrix
  69593. */
  69594. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  69595. /**
  69596. * Creates a translation matrix
  69597. * @param x defines the translation on X axis
  69598. * @param y defines the translation on Y axis
  69599. * @param z defines the translationon Z axis
  69600. * @returns the new matrix
  69601. */
  69602. static Translation(x: number, y: number, z: number): Matrix;
  69603. /**
  69604. * Creates a translation matrix and stores it in a given matrix
  69605. * @param x defines the translation on X axis
  69606. * @param y defines the translation on Y axis
  69607. * @param z defines the translationon Z axis
  69608. * @param result defines the target matrix
  69609. */
  69610. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  69611. /**
  69612. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69613. * @param startValue defines the start value
  69614. * @param endValue defines the end value
  69615. * @param gradient defines the gradient factor
  69616. * @returns the new matrix
  69617. */
  69618. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69619. /**
  69620. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69621. * @param startValue defines the start value
  69622. * @param endValue defines the end value
  69623. * @param gradient defines the gradient factor
  69624. * @param result defines the Matrix object where to store data
  69625. */
  69626. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69627. /**
  69628. * Builds a new matrix whose values are computed by:
  69629. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69630. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69631. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69632. * @param startValue defines the first matrix
  69633. * @param endValue defines the second matrix
  69634. * @param gradient defines the gradient between the two matrices
  69635. * @returns the new matrix
  69636. */
  69637. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69638. /**
  69639. * Update a matrix to values which are computed by:
  69640. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69641. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69642. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69643. * @param startValue defines the first matrix
  69644. * @param endValue defines the second matrix
  69645. * @param gradient defines the gradient between the two matrices
  69646. * @param result defines the target matrix
  69647. */
  69648. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69649. /**
  69650. * 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"
  69651. * This function works in left handed mode
  69652. * @param eye defines the final position of the entity
  69653. * @param target defines where the entity should look at
  69654. * @param up defines the up vector for the entity
  69655. * @returns the new matrix
  69656. */
  69657. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69658. /**
  69659. * 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".
  69660. * This function works in left handed mode
  69661. * @param eye defines the final position of the entity
  69662. * @param target defines where the entity should look at
  69663. * @param up defines the up vector for the entity
  69664. * @param result defines the target matrix
  69665. */
  69666. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69667. /**
  69668. * 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"
  69669. * This function works in right handed mode
  69670. * @param eye defines the final position of the entity
  69671. * @param target defines where the entity should look at
  69672. * @param up defines the up vector for the entity
  69673. * @returns the new matrix
  69674. */
  69675. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69676. /**
  69677. * 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".
  69678. * This function works in right handed mode
  69679. * @param eye defines the final position of the entity
  69680. * @param target defines where the entity should look at
  69681. * @param up defines the up vector for the entity
  69682. * @param result defines the target matrix
  69683. */
  69684. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69685. /**
  69686. * Create a left-handed orthographic projection matrix
  69687. * @param width defines the viewport width
  69688. * @param height defines the viewport height
  69689. * @param znear defines the near clip plane
  69690. * @param zfar defines the far clip plane
  69691. * @returns a new matrix as a left-handed orthographic projection matrix
  69692. */
  69693. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69694. /**
  69695. * Store a left-handed orthographic projection to a given matrix
  69696. * @param width defines the viewport width
  69697. * @param height defines the viewport height
  69698. * @param znear defines the near clip plane
  69699. * @param zfar defines the far clip plane
  69700. * @param result defines the target matrix
  69701. */
  69702. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  69703. /**
  69704. * Create a left-handed orthographic projection matrix
  69705. * @param left defines the viewport left coordinate
  69706. * @param right defines the viewport right coordinate
  69707. * @param bottom defines the viewport bottom coordinate
  69708. * @param top defines the viewport top coordinate
  69709. * @param znear defines the near clip plane
  69710. * @param zfar defines the far clip plane
  69711. * @returns a new matrix as a left-handed orthographic projection matrix
  69712. */
  69713. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69714. /**
  69715. * Stores a left-handed orthographic projection into a given matrix
  69716. * @param left defines the viewport left coordinate
  69717. * @param right defines the viewport right coordinate
  69718. * @param bottom defines the viewport bottom coordinate
  69719. * @param top defines the viewport top coordinate
  69720. * @param znear defines the near clip plane
  69721. * @param zfar defines the far clip plane
  69722. * @param result defines the target matrix
  69723. */
  69724. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69725. /**
  69726. * Creates a right-handed orthographic projection matrix
  69727. * @param left defines the viewport left coordinate
  69728. * @param right defines the viewport right coordinate
  69729. * @param bottom defines the viewport bottom coordinate
  69730. * @param top defines the viewport top coordinate
  69731. * @param znear defines the near clip plane
  69732. * @param zfar defines the far clip plane
  69733. * @returns a new matrix as a right-handed orthographic projection matrix
  69734. */
  69735. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69736. /**
  69737. * Stores a right-handed orthographic projection into a given matrix
  69738. * @param left defines the viewport left coordinate
  69739. * @param right defines the viewport right coordinate
  69740. * @param bottom defines the viewport bottom coordinate
  69741. * @param top defines the viewport top coordinate
  69742. * @param znear defines the near clip plane
  69743. * @param zfar defines the far clip plane
  69744. * @param result defines the target matrix
  69745. */
  69746. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69747. /**
  69748. * Creates a left-handed perspective projection matrix
  69749. * @param width defines the viewport width
  69750. * @param height defines the viewport height
  69751. * @param znear defines the near clip plane
  69752. * @param zfar defines the far clip plane
  69753. * @returns a new matrix as a left-handed perspective projection matrix
  69754. */
  69755. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69756. /**
  69757. * Creates a left-handed perspective projection matrix
  69758. * @param fov defines the horizontal field of view
  69759. * @param aspect defines the aspect ratio
  69760. * @param znear defines the near clip plane
  69761. * @param zfar defines the far clip plane
  69762. * @returns a new matrix as a left-handed perspective projection matrix
  69763. */
  69764. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69765. /**
  69766. * Stores a left-handed perspective projection into a given matrix
  69767. * @param fov defines the horizontal field of view
  69768. * @param aspect defines the aspect ratio
  69769. * @param znear defines the near clip plane
  69770. * @param zfar defines the far clip plane
  69771. * @param result defines the target matrix
  69772. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69773. */
  69774. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69775. /**
  69776. * Creates a right-handed perspective projection matrix
  69777. * @param fov defines the horizontal field of view
  69778. * @param aspect defines the aspect ratio
  69779. * @param znear defines the near clip plane
  69780. * @param zfar defines the far clip plane
  69781. * @returns a new matrix as a right-handed perspective projection matrix
  69782. */
  69783. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69784. /**
  69785. * Stores a right-handed perspective projection into a given matrix
  69786. * @param fov defines the horizontal field of view
  69787. * @param aspect defines the aspect ratio
  69788. * @param znear defines the near clip plane
  69789. * @param zfar defines the far clip plane
  69790. * @param result defines the target matrix
  69791. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69792. */
  69793. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69794. /**
  69795. * Stores a perspective projection for WebVR info a given matrix
  69796. * @param fov defines the field of view
  69797. * @param znear defines the near clip plane
  69798. * @param zfar defines the far clip plane
  69799. * @param result defines the target matrix
  69800. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  69801. */
  69802. static PerspectiveFovWebVRToRef(fov: {
  69803. upDegrees: number;
  69804. downDegrees: number;
  69805. leftDegrees: number;
  69806. rightDegrees: number;
  69807. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  69808. /**
  69809. * Computes a complete transformation matrix
  69810. * @param viewport defines the viewport to use
  69811. * @param world defines the world matrix
  69812. * @param view defines the view matrix
  69813. * @param projection defines the projection matrix
  69814. * @param zmin defines the near clip plane
  69815. * @param zmax defines the far clip plane
  69816. * @returns the transformation matrix
  69817. */
  69818. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  69819. /**
  69820. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  69821. * @param matrix defines the matrix to use
  69822. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  69823. */
  69824. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  69825. /**
  69826. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  69827. * @param matrix defines the matrix to use
  69828. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  69829. */
  69830. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  69831. /**
  69832. * Compute the transpose of a given matrix
  69833. * @param matrix defines the matrix to transpose
  69834. * @returns the new matrix
  69835. */
  69836. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  69837. /**
  69838. * Compute the transpose of a matrix and store it in a target matrix
  69839. * @param matrix defines the matrix to transpose
  69840. * @param result defines the target matrix
  69841. */
  69842. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  69843. /**
  69844. * Computes a reflection matrix from a plane
  69845. * @param plane defines the reflection plane
  69846. * @returns a new matrix
  69847. */
  69848. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  69849. /**
  69850. * Computes a reflection matrix from a plane
  69851. * @param plane defines the reflection plane
  69852. * @param result defines the target matrix
  69853. */
  69854. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  69855. /**
  69856. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  69857. * @param xaxis defines the value of the 1st axis
  69858. * @param yaxis defines the value of the 2nd axis
  69859. * @param zaxis defines the value of the 3rd axis
  69860. * @param result defines the target matrix
  69861. */
  69862. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  69863. /**
  69864. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  69865. * @param quat defines the quaternion to use
  69866. * @param result defines the target matrix
  69867. */
  69868. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  69869. }
  69870. /**
  69871. * @hidden
  69872. */
  69873. export class TmpVectors {
  69874. static Vector2: Vector2[];
  69875. static Vector3: Vector3[];
  69876. static Vector4: Vector4[];
  69877. static Quaternion: Quaternion[];
  69878. static Matrix: Matrix[];
  69879. }
  69880. }
  69881. declare module BABYLON {
  69882. /**
  69883. * Class used to hold a RBG color
  69884. */
  69885. export class Color3 {
  69886. /**
  69887. * Defines the red component (between 0 and 1, default is 0)
  69888. */
  69889. r: number;
  69890. /**
  69891. * Defines the green component (between 0 and 1, default is 0)
  69892. */
  69893. g: number;
  69894. /**
  69895. * Defines the blue component (between 0 and 1, default is 0)
  69896. */
  69897. b: number;
  69898. /**
  69899. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  69900. * @param r defines the red component (between 0 and 1, default is 0)
  69901. * @param g defines the green component (between 0 and 1, default is 0)
  69902. * @param b defines the blue component (between 0 and 1, default is 0)
  69903. */
  69904. constructor(
  69905. /**
  69906. * Defines the red component (between 0 and 1, default is 0)
  69907. */
  69908. r?: number,
  69909. /**
  69910. * Defines the green component (between 0 and 1, default is 0)
  69911. */
  69912. g?: number,
  69913. /**
  69914. * Defines the blue component (between 0 and 1, default is 0)
  69915. */
  69916. b?: number);
  69917. /**
  69918. * Creates a string with the Color3 current values
  69919. * @returns the string representation of the Color3 object
  69920. */
  69921. toString(): string;
  69922. /**
  69923. * Returns the string "Color3"
  69924. * @returns "Color3"
  69925. */
  69926. getClassName(): string;
  69927. /**
  69928. * Compute the Color3 hash code
  69929. * @returns an unique number that can be used to hash Color3 objects
  69930. */
  69931. getHashCode(): number;
  69932. /**
  69933. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  69934. * @param array defines the array where to store the r,g,b components
  69935. * @param index defines an optional index in the target array to define where to start storing values
  69936. * @returns the current Color3 object
  69937. */
  69938. toArray(array: FloatArray, index?: number): Color3;
  69939. /**
  69940. * Returns a new Color4 object from the current Color3 and the given alpha
  69941. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  69942. * @returns a new Color4 object
  69943. */
  69944. toColor4(alpha?: number): Color4;
  69945. /**
  69946. * Returns a new array populated with 3 numeric elements : red, green and blue values
  69947. * @returns the new array
  69948. */
  69949. asArray(): number[];
  69950. /**
  69951. * Returns the luminance value
  69952. * @returns a float value
  69953. */
  69954. toLuminance(): number;
  69955. /**
  69956. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  69957. * @param otherColor defines the second operand
  69958. * @returns the new Color3 object
  69959. */
  69960. multiply(otherColor: DeepImmutable<Color3>): Color3;
  69961. /**
  69962. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  69963. * @param otherColor defines the second operand
  69964. * @param result defines the Color3 object where to store the result
  69965. * @returns the current Color3
  69966. */
  69967. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69968. /**
  69969. * Determines equality between Color3 objects
  69970. * @param otherColor defines the second operand
  69971. * @returns true if the rgb values are equal to the given ones
  69972. */
  69973. equals(otherColor: DeepImmutable<Color3>): boolean;
  69974. /**
  69975. * Determines equality between the current Color3 object and a set of r,b,g values
  69976. * @param r defines the red component to check
  69977. * @param g defines the green component to check
  69978. * @param b defines the blue component to check
  69979. * @returns true if the rgb values are equal to the given ones
  69980. */
  69981. equalsFloats(r: number, g: number, b: number): boolean;
  69982. /**
  69983. * Multiplies in place each rgb value by scale
  69984. * @param scale defines the scaling factor
  69985. * @returns the updated Color3
  69986. */
  69987. scale(scale: number): Color3;
  69988. /**
  69989. * Multiplies the rgb values by scale and stores the result into "result"
  69990. * @param scale defines the scaling factor
  69991. * @param result defines the Color3 object where to store the result
  69992. * @returns the unmodified current Color3
  69993. */
  69994. scaleToRef(scale: number, result: Color3): Color3;
  69995. /**
  69996. * Scale the current Color3 values by a factor and add the result to a given Color3
  69997. * @param scale defines the scale factor
  69998. * @param result defines color to store the result into
  69999. * @returns the unmodified current Color3
  70000. */
  70001. scaleAndAddToRef(scale: number, result: Color3): Color3;
  70002. /**
  70003. * Clamps the rgb values by the min and max values and stores the result into "result"
  70004. * @param min defines minimum clamping value (default is 0)
  70005. * @param max defines maximum clamping value (default is 1)
  70006. * @param result defines color to store the result into
  70007. * @returns the original Color3
  70008. */
  70009. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  70010. /**
  70011. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70012. * @param otherColor defines the second operand
  70013. * @returns the new Color3
  70014. */
  70015. add(otherColor: DeepImmutable<Color3>): Color3;
  70016. /**
  70017. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70018. * @param otherColor defines the second operand
  70019. * @param result defines Color3 object to store the result into
  70020. * @returns the unmodified current Color3
  70021. */
  70022. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70023. /**
  70024. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70025. * @param otherColor defines the second operand
  70026. * @returns the new Color3
  70027. */
  70028. subtract(otherColor: DeepImmutable<Color3>): Color3;
  70029. /**
  70030. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70031. * @param otherColor defines the second operand
  70032. * @param result defines Color3 object to store the result into
  70033. * @returns the unmodified current Color3
  70034. */
  70035. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70036. /**
  70037. * Copy the current object
  70038. * @returns a new Color3 copied the current one
  70039. */
  70040. clone(): Color3;
  70041. /**
  70042. * Copies the rgb values from the source in the current Color3
  70043. * @param source defines the source Color3 object
  70044. * @returns the updated Color3 object
  70045. */
  70046. copyFrom(source: DeepImmutable<Color3>): Color3;
  70047. /**
  70048. * Updates the Color3 rgb values from the given floats
  70049. * @param r defines the red component to read from
  70050. * @param g defines the green component to read from
  70051. * @param b defines the blue component to read from
  70052. * @returns the current Color3 object
  70053. */
  70054. copyFromFloats(r: number, g: number, b: number): Color3;
  70055. /**
  70056. * Updates the Color3 rgb values from the given floats
  70057. * @param r defines the red component to read from
  70058. * @param g defines the green component to read from
  70059. * @param b defines the blue component to read from
  70060. * @returns the current Color3 object
  70061. */
  70062. set(r: number, g: number, b: number): Color3;
  70063. /**
  70064. * Compute the Color3 hexadecimal code as a string
  70065. * @returns a string containing the hexadecimal representation of the Color3 object
  70066. */
  70067. toHexString(): string;
  70068. /**
  70069. * Computes a new Color3 converted from the current one to linear space
  70070. * @returns a new Color3 object
  70071. */
  70072. toLinearSpace(): Color3;
  70073. /**
  70074. * Converts current color in rgb space to HSV values
  70075. * @returns a new color3 representing the HSV values
  70076. */
  70077. toHSV(): Color3;
  70078. /**
  70079. * Converts current color in rgb space to HSV values
  70080. * @param result defines the Color3 where to store the HSV values
  70081. */
  70082. toHSVToRef(result: Color3): void;
  70083. /**
  70084. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70085. * @param convertedColor defines the Color3 object where to store the linear space version
  70086. * @returns the unmodified Color3
  70087. */
  70088. toLinearSpaceToRef(convertedColor: Color3): Color3;
  70089. /**
  70090. * Computes a new Color3 converted from the current one to gamma space
  70091. * @returns a new Color3 object
  70092. */
  70093. toGammaSpace(): Color3;
  70094. /**
  70095. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70096. * @param convertedColor defines the Color3 object where to store the gamma space version
  70097. * @returns the unmodified Color3
  70098. */
  70099. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70100. private static _BlackReadOnly;
  70101. /**
  70102. * Convert Hue, saturation and value to a Color3 (RGB)
  70103. * @param hue defines the hue
  70104. * @param saturation defines the saturation
  70105. * @param value defines the value
  70106. * @param result defines the Color3 where to store the RGB values
  70107. */
  70108. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70109. /**
  70110. * Creates a new Color3 from the string containing valid hexadecimal values
  70111. * @param hex defines a string containing valid hexadecimal values
  70112. * @returns a new Color3 object
  70113. */
  70114. static FromHexString(hex: string): Color3;
  70115. /**
  70116. * Creates a new Color3 from the starting index of the given array
  70117. * @param array defines the source array
  70118. * @param offset defines an offset in the source array
  70119. * @returns a new Color3 object
  70120. */
  70121. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70122. /**
  70123. * Creates a new Color3 from integer values (< 256)
  70124. * @param r defines the red component to read from (value between 0 and 255)
  70125. * @param g defines the green component to read from (value between 0 and 255)
  70126. * @param b defines the blue component to read from (value between 0 and 255)
  70127. * @returns a new Color3 object
  70128. */
  70129. static FromInts(r: number, g: number, b: number): Color3;
  70130. /**
  70131. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70132. * @param start defines the start Color3 value
  70133. * @param end defines the end Color3 value
  70134. * @param amount defines the gradient value between start and end
  70135. * @returns a new Color3 object
  70136. */
  70137. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70138. /**
  70139. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70140. * @param left defines the start value
  70141. * @param right defines the end value
  70142. * @param amount defines the gradient factor
  70143. * @param result defines the Color3 object where to store the result
  70144. */
  70145. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70146. /**
  70147. * Returns a Color3 value containing a red color
  70148. * @returns a new Color3 object
  70149. */
  70150. static Red(): Color3;
  70151. /**
  70152. * Returns a Color3 value containing a green color
  70153. * @returns a new Color3 object
  70154. */
  70155. static Green(): Color3;
  70156. /**
  70157. * Returns a Color3 value containing a blue color
  70158. * @returns a new Color3 object
  70159. */
  70160. static Blue(): Color3;
  70161. /**
  70162. * Returns a Color3 value containing a black color
  70163. * @returns a new Color3 object
  70164. */
  70165. static Black(): Color3;
  70166. /**
  70167. * Gets a Color3 value containing a black color that must not be updated
  70168. */
  70169. static readonly BlackReadOnly: DeepImmutable<Color3>;
  70170. /**
  70171. * Returns a Color3 value containing a white color
  70172. * @returns a new Color3 object
  70173. */
  70174. static White(): Color3;
  70175. /**
  70176. * Returns a Color3 value containing a purple color
  70177. * @returns a new Color3 object
  70178. */
  70179. static Purple(): Color3;
  70180. /**
  70181. * Returns a Color3 value containing a magenta color
  70182. * @returns a new Color3 object
  70183. */
  70184. static Magenta(): Color3;
  70185. /**
  70186. * Returns a Color3 value containing a yellow color
  70187. * @returns a new Color3 object
  70188. */
  70189. static Yellow(): Color3;
  70190. /**
  70191. * Returns a Color3 value containing a gray color
  70192. * @returns a new Color3 object
  70193. */
  70194. static Gray(): Color3;
  70195. /**
  70196. * Returns a Color3 value containing a teal color
  70197. * @returns a new Color3 object
  70198. */
  70199. static Teal(): Color3;
  70200. /**
  70201. * Returns a Color3 value containing a random color
  70202. * @returns a new Color3 object
  70203. */
  70204. static Random(): Color3;
  70205. }
  70206. /**
  70207. * Class used to hold a RBGA color
  70208. */
  70209. export class Color4 {
  70210. /**
  70211. * Defines the red component (between 0 and 1, default is 0)
  70212. */
  70213. r: number;
  70214. /**
  70215. * Defines the green component (between 0 and 1, default is 0)
  70216. */
  70217. g: number;
  70218. /**
  70219. * Defines the blue component (between 0 and 1, default is 0)
  70220. */
  70221. b: number;
  70222. /**
  70223. * Defines the alpha component (between 0 and 1, default is 1)
  70224. */
  70225. a: number;
  70226. /**
  70227. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70228. * @param r defines the red component (between 0 and 1, default is 0)
  70229. * @param g defines the green component (between 0 and 1, default is 0)
  70230. * @param b defines the blue component (between 0 and 1, default is 0)
  70231. * @param a defines the alpha component (between 0 and 1, default is 1)
  70232. */
  70233. constructor(
  70234. /**
  70235. * Defines the red component (between 0 and 1, default is 0)
  70236. */
  70237. r?: number,
  70238. /**
  70239. * Defines the green component (between 0 and 1, default is 0)
  70240. */
  70241. g?: number,
  70242. /**
  70243. * Defines the blue component (between 0 and 1, default is 0)
  70244. */
  70245. b?: number,
  70246. /**
  70247. * Defines the alpha component (between 0 and 1, default is 1)
  70248. */
  70249. a?: number);
  70250. /**
  70251. * Adds in place the given Color4 values to the current Color4 object
  70252. * @param right defines the second operand
  70253. * @returns the current updated Color4 object
  70254. */
  70255. addInPlace(right: DeepImmutable<Color4>): Color4;
  70256. /**
  70257. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70258. * @returns the new array
  70259. */
  70260. asArray(): number[];
  70261. /**
  70262. * Stores from the starting index in the given array the Color4 successive values
  70263. * @param array defines the array where to store the r,g,b components
  70264. * @param index defines an optional index in the target array to define where to start storing values
  70265. * @returns the current Color4 object
  70266. */
  70267. toArray(array: number[], index?: number): Color4;
  70268. /**
  70269. * Determines equality between Color4 objects
  70270. * @param otherColor defines the second operand
  70271. * @returns true if the rgba values are equal to the given ones
  70272. */
  70273. equals(otherColor: DeepImmutable<Color4>): boolean;
  70274. /**
  70275. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70276. * @param right defines the second operand
  70277. * @returns a new Color4 object
  70278. */
  70279. add(right: DeepImmutable<Color4>): Color4;
  70280. /**
  70281. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70282. * @param right defines the second operand
  70283. * @returns a new Color4 object
  70284. */
  70285. subtract(right: DeepImmutable<Color4>): Color4;
  70286. /**
  70287. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70288. * @param right defines the second operand
  70289. * @param result defines the Color4 object where to store the result
  70290. * @returns the current Color4 object
  70291. */
  70292. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  70293. /**
  70294. * Creates a new Color4 with the current Color4 values multiplied by scale
  70295. * @param scale defines the scaling factor to apply
  70296. * @returns a new Color4 object
  70297. */
  70298. scale(scale: number): Color4;
  70299. /**
  70300. * Multiplies the current Color4 values by scale and stores the result in "result"
  70301. * @param scale defines the scaling factor to apply
  70302. * @param result defines the Color4 object where to store the result
  70303. * @returns the current unmodified Color4
  70304. */
  70305. scaleToRef(scale: number, result: Color4): Color4;
  70306. /**
  70307. * Scale the current Color4 values by a factor and add the result to a given Color4
  70308. * @param scale defines the scale factor
  70309. * @param result defines the Color4 object where to store the result
  70310. * @returns the unmodified current Color4
  70311. */
  70312. scaleAndAddToRef(scale: number, result: Color4): Color4;
  70313. /**
  70314. * Clamps the rgb values by the min and max values and stores the result into "result"
  70315. * @param min defines minimum clamping value (default is 0)
  70316. * @param max defines maximum clamping value (default is 1)
  70317. * @param result defines color to store the result into.
  70318. * @returns the cuurent Color4
  70319. */
  70320. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  70321. /**
  70322. * Multipy an Color4 value by another and return a new Color4 object
  70323. * @param color defines the Color4 value to multiply by
  70324. * @returns a new Color4 object
  70325. */
  70326. multiply(color: Color4): Color4;
  70327. /**
  70328. * Multipy a Color4 value by another and push the result in a reference value
  70329. * @param color defines the Color4 value to multiply by
  70330. * @param result defines the Color4 to fill the result in
  70331. * @returns the result Color4
  70332. */
  70333. multiplyToRef(color: Color4, result: Color4): Color4;
  70334. /**
  70335. * Creates a string with the Color4 current values
  70336. * @returns the string representation of the Color4 object
  70337. */
  70338. toString(): string;
  70339. /**
  70340. * Returns the string "Color4"
  70341. * @returns "Color4"
  70342. */
  70343. getClassName(): string;
  70344. /**
  70345. * Compute the Color4 hash code
  70346. * @returns an unique number that can be used to hash Color4 objects
  70347. */
  70348. getHashCode(): number;
  70349. /**
  70350. * Creates a new Color4 copied from the current one
  70351. * @returns a new Color4 object
  70352. */
  70353. clone(): Color4;
  70354. /**
  70355. * Copies the given Color4 values into the current one
  70356. * @param source defines the source Color4 object
  70357. * @returns the current updated Color4 object
  70358. */
  70359. copyFrom(source: Color4): Color4;
  70360. /**
  70361. * Copies the given float values into the current one
  70362. * @param r defines the red component to read from
  70363. * @param g defines the green component to read from
  70364. * @param b defines the blue component to read from
  70365. * @param a defines the alpha component to read from
  70366. * @returns the current updated Color4 object
  70367. */
  70368. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  70369. /**
  70370. * Copies the given float values into the current one
  70371. * @param r defines the red component to read from
  70372. * @param g defines the green component to read from
  70373. * @param b defines the blue component to read from
  70374. * @param a defines the alpha component to read from
  70375. * @returns the current updated Color4 object
  70376. */
  70377. set(r: number, g: number, b: number, a: number): Color4;
  70378. /**
  70379. * Compute the Color4 hexadecimal code as a string
  70380. * @returns a string containing the hexadecimal representation of the Color4 object
  70381. */
  70382. toHexString(): string;
  70383. /**
  70384. * Computes a new Color4 converted from the current one to linear space
  70385. * @returns a new Color4 object
  70386. */
  70387. toLinearSpace(): Color4;
  70388. /**
  70389. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  70390. * @param convertedColor defines the Color4 object where to store the linear space version
  70391. * @returns the unmodified Color4
  70392. */
  70393. toLinearSpaceToRef(convertedColor: Color4): Color4;
  70394. /**
  70395. * Computes a new Color4 converted from the current one to gamma space
  70396. * @returns a new Color4 object
  70397. */
  70398. toGammaSpace(): Color4;
  70399. /**
  70400. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  70401. * @param convertedColor defines the Color4 object where to store the gamma space version
  70402. * @returns the unmodified Color4
  70403. */
  70404. toGammaSpaceToRef(convertedColor: Color4): Color4;
  70405. /**
  70406. * Creates a new Color4 from the string containing valid hexadecimal values
  70407. * @param hex defines a string containing valid hexadecimal values
  70408. * @returns a new Color4 object
  70409. */
  70410. static FromHexString(hex: string): Color4;
  70411. /**
  70412. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70413. * @param left defines the start value
  70414. * @param right defines the end value
  70415. * @param amount defines the gradient factor
  70416. * @returns a new Color4 object
  70417. */
  70418. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  70419. /**
  70420. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70421. * @param left defines the start value
  70422. * @param right defines the end value
  70423. * @param amount defines the gradient factor
  70424. * @param result defines the Color4 object where to store data
  70425. */
  70426. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  70427. /**
  70428. * Creates a new Color4 from a Color3 and an alpha value
  70429. * @param color3 defines the source Color3 to read from
  70430. * @param alpha defines the alpha component (1.0 by default)
  70431. * @returns a new Color4 object
  70432. */
  70433. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  70434. /**
  70435. * Creates a new Color4 from the starting index element of the given array
  70436. * @param array defines the source array to read from
  70437. * @param offset defines the offset in the source array
  70438. * @returns a new Color4 object
  70439. */
  70440. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  70441. /**
  70442. * Creates a new Color3 from integer values (< 256)
  70443. * @param r defines the red component to read from (value between 0 and 255)
  70444. * @param g defines the green component to read from (value between 0 and 255)
  70445. * @param b defines the blue component to read from (value between 0 and 255)
  70446. * @param a defines the alpha component to read from (value between 0 and 255)
  70447. * @returns a new Color3 object
  70448. */
  70449. static FromInts(r: number, g: number, b: number, a: number): Color4;
  70450. /**
  70451. * Check the content of a given array and convert it to an array containing RGBA data
  70452. * If the original array was already containing count * 4 values then it is returned directly
  70453. * @param colors defines the array to check
  70454. * @param count defines the number of RGBA data to expect
  70455. * @returns an array containing count * 4 values (RGBA)
  70456. */
  70457. static CheckColors4(colors: number[], count: number): number[];
  70458. }
  70459. /**
  70460. * @hidden
  70461. */
  70462. export class TmpColors {
  70463. static Color3: Color3[];
  70464. static Color4: Color4[];
  70465. }
  70466. }
  70467. declare module BABYLON {
  70468. /**
  70469. * Class representing spherical harmonics coefficients to the 3rd degree
  70470. */
  70471. export class SphericalHarmonics {
  70472. /**
  70473. * Defines whether or not the harmonics have been prescaled for rendering.
  70474. */
  70475. preScaled: boolean;
  70476. /**
  70477. * The l0,0 coefficients of the spherical harmonics
  70478. */
  70479. l00: Vector3;
  70480. /**
  70481. * The l1,-1 coefficients of the spherical harmonics
  70482. */
  70483. l1_1: Vector3;
  70484. /**
  70485. * The l1,0 coefficients of the spherical harmonics
  70486. */
  70487. l10: Vector3;
  70488. /**
  70489. * The l1,1 coefficients of the spherical harmonics
  70490. */
  70491. l11: Vector3;
  70492. /**
  70493. * The l2,-2 coefficients of the spherical harmonics
  70494. */
  70495. l2_2: Vector3;
  70496. /**
  70497. * The l2,-1 coefficients of the spherical harmonics
  70498. */
  70499. l2_1: Vector3;
  70500. /**
  70501. * The l2,0 coefficients of the spherical harmonics
  70502. */
  70503. l20: Vector3;
  70504. /**
  70505. * The l2,1 coefficients of the spherical harmonics
  70506. */
  70507. l21: Vector3;
  70508. /**
  70509. * The l2,2 coefficients of the spherical harmonics
  70510. */
  70511. l22: Vector3;
  70512. /**
  70513. * Adds a light to the spherical harmonics
  70514. * @param direction the direction of the light
  70515. * @param color the color of the light
  70516. * @param deltaSolidAngle the delta solid angle of the light
  70517. */
  70518. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  70519. /**
  70520. * Scales the spherical harmonics by the given amount
  70521. * @param scale the amount to scale
  70522. */
  70523. scaleInPlace(scale: number): void;
  70524. /**
  70525. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  70526. *
  70527. * ```
  70528. * E_lm = A_l * L_lm
  70529. * ```
  70530. *
  70531. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  70532. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  70533. * the scaling factors are given in equation 9.
  70534. */
  70535. convertIncidentRadianceToIrradiance(): void;
  70536. /**
  70537. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  70538. *
  70539. * ```
  70540. * L = (1/pi) * E * rho
  70541. * ```
  70542. *
  70543. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  70544. */
  70545. convertIrradianceToLambertianRadiance(): void;
  70546. /**
  70547. * Integrates the reconstruction coefficients directly in to the SH preventing further
  70548. * required operations at run time.
  70549. *
  70550. * This is simply done by scaling back the SH with Ylm constants parameter.
  70551. * The trigonometric part being applied by the shader at run time.
  70552. */
  70553. preScaleForRendering(): void;
  70554. /**
  70555. * Constructs a spherical harmonics from an array.
  70556. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  70557. * @returns the spherical harmonics
  70558. */
  70559. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  70560. /**
  70561. * Gets the spherical harmonics from polynomial
  70562. * @param polynomial the spherical polynomial
  70563. * @returns the spherical harmonics
  70564. */
  70565. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  70566. }
  70567. /**
  70568. * Class representing spherical polynomial coefficients to the 3rd degree
  70569. */
  70570. export class SphericalPolynomial {
  70571. private _harmonics;
  70572. /**
  70573. * The spherical harmonics used to create the polynomials.
  70574. */
  70575. readonly preScaledHarmonics: SphericalHarmonics;
  70576. /**
  70577. * The x coefficients of the spherical polynomial
  70578. */
  70579. x: Vector3;
  70580. /**
  70581. * The y coefficients of the spherical polynomial
  70582. */
  70583. y: Vector3;
  70584. /**
  70585. * The z coefficients of the spherical polynomial
  70586. */
  70587. z: Vector3;
  70588. /**
  70589. * The xx coefficients of the spherical polynomial
  70590. */
  70591. xx: Vector3;
  70592. /**
  70593. * The yy coefficients of the spherical polynomial
  70594. */
  70595. yy: Vector3;
  70596. /**
  70597. * The zz coefficients of the spherical polynomial
  70598. */
  70599. zz: Vector3;
  70600. /**
  70601. * The xy coefficients of the spherical polynomial
  70602. */
  70603. xy: Vector3;
  70604. /**
  70605. * The yz coefficients of the spherical polynomial
  70606. */
  70607. yz: Vector3;
  70608. /**
  70609. * The zx coefficients of the spherical polynomial
  70610. */
  70611. zx: Vector3;
  70612. /**
  70613. * Adds an ambient color to the spherical polynomial
  70614. * @param color the color to add
  70615. */
  70616. addAmbient(color: Color3): void;
  70617. /**
  70618. * Scales the spherical polynomial by the given amount
  70619. * @param scale the amount to scale
  70620. */
  70621. scaleInPlace(scale: number): void;
  70622. /**
  70623. * Gets the spherical polynomial from harmonics
  70624. * @param harmonics the spherical harmonics
  70625. * @returns the spherical polynomial
  70626. */
  70627. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  70628. /**
  70629. * Constructs a spherical polynomial from an array.
  70630. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  70631. * @returns the spherical polynomial
  70632. */
  70633. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  70634. }
  70635. }
  70636. declare module BABYLON {
  70637. /**
  70638. * Define options used to create a render target texture
  70639. */
  70640. export class RenderTargetCreationOptions {
  70641. /**
  70642. * Specifies is mipmaps must be generated
  70643. */
  70644. generateMipMaps?: boolean;
  70645. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  70646. generateDepthBuffer?: boolean;
  70647. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  70648. generateStencilBuffer?: boolean;
  70649. /** Defines texture type (int by default) */
  70650. type?: number;
  70651. /** Defines sampling mode (trilinear by default) */
  70652. samplingMode?: number;
  70653. /** Defines format (RGBA by default) */
  70654. format?: number;
  70655. }
  70656. }
  70657. declare module BABYLON {
  70658. /**
  70659. * @hidden
  70660. **/
  70661. export class _TimeToken {
  70662. _startTimeQuery: Nullable<WebGLQuery>;
  70663. _endTimeQuery: Nullable<WebGLQuery>;
  70664. _timeElapsedQuery: Nullable<WebGLQuery>;
  70665. _timeElapsedQueryEnded: boolean;
  70666. }
  70667. }
  70668. declare module BABYLON {
  70669. /** Defines the cross module used constants to avoid circular dependncies */
  70670. export class Constants {
  70671. /** Defines that alpha blending is disabled */
  70672. static readonly ALPHA_DISABLE: number;
  70673. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  70674. static readonly ALPHA_ADD: number;
  70675. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  70676. static readonly ALPHA_COMBINE: number;
  70677. /** Defines that alpha blending to DEST - SRC * DEST */
  70678. static readonly ALPHA_SUBTRACT: number;
  70679. /** Defines that alpha blending to SRC * DEST */
  70680. static readonly ALPHA_MULTIPLY: number;
  70681. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  70682. static readonly ALPHA_MAXIMIZED: number;
  70683. /** Defines that alpha blending to SRC + DEST */
  70684. static readonly ALPHA_ONEONE: number;
  70685. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  70686. static readonly ALPHA_PREMULTIPLIED: number;
  70687. /**
  70688. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  70689. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  70690. */
  70691. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  70692. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  70693. static readonly ALPHA_INTERPOLATE: number;
  70694. /**
  70695. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  70696. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  70697. */
  70698. static readonly ALPHA_SCREENMODE: number;
  70699. /**
  70700. * Defines that alpha blending to SRC + DST
  70701. * Alpha will be set to SRC ALPHA + DST ALPHA
  70702. */
  70703. static readonly ALPHA_ONEONE_ONEONE: number;
  70704. /**
  70705. * Defines that alpha blending to SRC * DST ALPHA + DST
  70706. * Alpha will be set to 0
  70707. */
  70708. static readonly ALPHA_ALPHATOCOLOR: number;
  70709. /**
  70710. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  70711. */
  70712. static readonly ALPHA_REVERSEONEMINUS: number;
  70713. /**
  70714. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  70715. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  70716. */
  70717. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  70718. /**
  70719. * Defines that alpha blending to SRC + DST
  70720. * Alpha will be set to SRC ALPHA
  70721. */
  70722. static readonly ALPHA_ONEONE_ONEZERO: number;
  70723. /** Defines that alpha blending equation a SUM */
  70724. static readonly ALPHA_EQUATION_ADD: number;
  70725. /** Defines that alpha blending equation a SUBSTRACTION */
  70726. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  70727. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  70728. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  70729. /** Defines that alpha blending equation a MAX operation */
  70730. static readonly ALPHA_EQUATION_MAX: number;
  70731. /** Defines that alpha blending equation a MIN operation */
  70732. static readonly ALPHA_EQUATION_MIN: number;
  70733. /**
  70734. * Defines that alpha blending equation a DARKEN operation:
  70735. * It takes the min of the src and sums the alpha channels.
  70736. */
  70737. static readonly ALPHA_EQUATION_DARKEN: number;
  70738. /** Defines that the ressource is not delayed*/
  70739. static readonly DELAYLOADSTATE_NONE: number;
  70740. /** Defines that the ressource was successfully delay loaded */
  70741. static readonly DELAYLOADSTATE_LOADED: number;
  70742. /** Defines that the ressource is currently delay loading */
  70743. static readonly DELAYLOADSTATE_LOADING: number;
  70744. /** Defines that the ressource is delayed and has not started loading */
  70745. static readonly DELAYLOADSTATE_NOTLOADED: number;
  70746. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  70747. static readonly NEVER: number;
  70748. /** 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 */
  70749. static readonly ALWAYS: number;
  70750. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  70751. static readonly LESS: number;
  70752. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  70753. static readonly EQUAL: number;
  70754. /** 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 */
  70755. static readonly LEQUAL: number;
  70756. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  70757. static readonly GREATER: number;
  70758. /** 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 */
  70759. static readonly GEQUAL: number;
  70760. /** 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 */
  70761. static readonly NOTEQUAL: number;
  70762. /** Passed to stencilOperation to specify that stencil value must be kept */
  70763. static readonly KEEP: number;
  70764. /** Passed to stencilOperation to specify that stencil value must be replaced */
  70765. static readonly REPLACE: number;
  70766. /** Passed to stencilOperation to specify that stencil value must be incremented */
  70767. static readonly INCR: number;
  70768. /** Passed to stencilOperation to specify that stencil value must be decremented */
  70769. static readonly DECR: number;
  70770. /** Passed to stencilOperation to specify that stencil value must be inverted */
  70771. static readonly INVERT: number;
  70772. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  70773. static readonly INCR_WRAP: number;
  70774. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  70775. static readonly DECR_WRAP: number;
  70776. /** Texture is not repeating outside of 0..1 UVs */
  70777. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  70778. /** Texture is repeating outside of 0..1 UVs */
  70779. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  70780. /** Texture is repeating and mirrored */
  70781. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  70782. /** ALPHA */
  70783. static readonly TEXTUREFORMAT_ALPHA: number;
  70784. /** LUMINANCE */
  70785. static readonly TEXTUREFORMAT_LUMINANCE: number;
  70786. /** LUMINANCE_ALPHA */
  70787. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  70788. /** RGB */
  70789. static readonly TEXTUREFORMAT_RGB: number;
  70790. /** RGBA */
  70791. static readonly TEXTUREFORMAT_RGBA: number;
  70792. /** RED */
  70793. static readonly TEXTUREFORMAT_RED: number;
  70794. /** RED (2nd reference) */
  70795. static readonly TEXTUREFORMAT_R: number;
  70796. /** RG */
  70797. static readonly TEXTUREFORMAT_RG: number;
  70798. /** RED_INTEGER */
  70799. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  70800. /** RED_INTEGER (2nd reference) */
  70801. static readonly TEXTUREFORMAT_R_INTEGER: number;
  70802. /** RG_INTEGER */
  70803. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  70804. /** RGB_INTEGER */
  70805. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  70806. /** RGBA_INTEGER */
  70807. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  70808. /** UNSIGNED_BYTE */
  70809. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  70810. /** UNSIGNED_BYTE (2nd reference) */
  70811. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  70812. /** FLOAT */
  70813. static readonly TEXTURETYPE_FLOAT: number;
  70814. /** HALF_FLOAT */
  70815. static readonly TEXTURETYPE_HALF_FLOAT: number;
  70816. /** BYTE */
  70817. static readonly TEXTURETYPE_BYTE: number;
  70818. /** SHORT */
  70819. static readonly TEXTURETYPE_SHORT: number;
  70820. /** UNSIGNED_SHORT */
  70821. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  70822. /** INT */
  70823. static readonly TEXTURETYPE_INT: number;
  70824. /** UNSIGNED_INT */
  70825. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  70826. /** UNSIGNED_SHORT_4_4_4_4 */
  70827. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  70828. /** UNSIGNED_SHORT_5_5_5_1 */
  70829. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  70830. /** UNSIGNED_SHORT_5_6_5 */
  70831. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  70832. /** UNSIGNED_INT_2_10_10_10_REV */
  70833. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  70834. /** UNSIGNED_INT_24_8 */
  70835. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  70836. /** UNSIGNED_INT_10F_11F_11F_REV */
  70837. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  70838. /** UNSIGNED_INT_5_9_9_9_REV */
  70839. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  70840. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  70841. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70842. /** nearest is mag = nearest and min = nearest and mip = linear */
  70843. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  70844. /** Bilinear is mag = linear and min = linear and mip = nearest */
  70845. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  70846. /** Trilinear is mag = linear and min = linear and mip = linear */
  70847. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  70848. /** nearest is mag = nearest and min = nearest and mip = linear */
  70849. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  70850. /** Bilinear is mag = linear and min = linear and mip = nearest */
  70851. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  70852. /** Trilinear is mag = linear and min = linear and mip = linear */
  70853. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  70854. /** mag = nearest and min = nearest and mip = nearest */
  70855. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  70856. /** mag = nearest and min = linear and mip = nearest */
  70857. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  70858. /** mag = nearest and min = linear and mip = linear */
  70859. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  70860. /** mag = nearest and min = linear and mip = none */
  70861. static readonly TEXTURE_NEAREST_LINEAR: number;
  70862. /** mag = nearest and min = nearest and mip = none */
  70863. static readonly TEXTURE_NEAREST_NEAREST: number;
  70864. /** mag = linear and min = nearest and mip = nearest */
  70865. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  70866. /** mag = linear and min = nearest and mip = linear */
  70867. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  70868. /** mag = linear and min = linear and mip = none */
  70869. static readonly TEXTURE_LINEAR_LINEAR: number;
  70870. /** mag = linear and min = nearest and mip = none */
  70871. static readonly TEXTURE_LINEAR_NEAREST: number;
  70872. /** Explicit coordinates mode */
  70873. static readonly TEXTURE_EXPLICIT_MODE: number;
  70874. /** Spherical coordinates mode */
  70875. static readonly TEXTURE_SPHERICAL_MODE: number;
  70876. /** Planar coordinates mode */
  70877. static readonly TEXTURE_PLANAR_MODE: number;
  70878. /** Cubic coordinates mode */
  70879. static readonly TEXTURE_CUBIC_MODE: number;
  70880. /** Projection coordinates mode */
  70881. static readonly TEXTURE_PROJECTION_MODE: number;
  70882. /** Skybox coordinates mode */
  70883. static readonly TEXTURE_SKYBOX_MODE: number;
  70884. /** Inverse Cubic coordinates mode */
  70885. static readonly TEXTURE_INVCUBIC_MODE: number;
  70886. /** Equirectangular coordinates mode */
  70887. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  70888. /** Equirectangular Fixed coordinates mode */
  70889. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  70890. /** Equirectangular Fixed Mirrored coordinates mode */
  70891. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  70892. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  70893. static readonly SCALEMODE_FLOOR: number;
  70894. /** Defines that texture rescaling will look for the nearest power of 2 size */
  70895. static readonly SCALEMODE_NEAREST: number;
  70896. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  70897. static readonly SCALEMODE_CEILING: number;
  70898. /**
  70899. * The dirty texture flag value
  70900. */
  70901. static readonly MATERIAL_TextureDirtyFlag: number;
  70902. /**
  70903. * The dirty light flag value
  70904. */
  70905. static readonly MATERIAL_LightDirtyFlag: number;
  70906. /**
  70907. * The dirty fresnel flag value
  70908. */
  70909. static readonly MATERIAL_FresnelDirtyFlag: number;
  70910. /**
  70911. * The dirty attribute flag value
  70912. */
  70913. static readonly MATERIAL_AttributesDirtyFlag: number;
  70914. /**
  70915. * The dirty misc flag value
  70916. */
  70917. static readonly MATERIAL_MiscDirtyFlag: number;
  70918. /**
  70919. * The all dirty flag value
  70920. */
  70921. static readonly MATERIAL_AllDirtyFlag: number;
  70922. /**
  70923. * Returns the triangle fill mode
  70924. */
  70925. static readonly MATERIAL_TriangleFillMode: number;
  70926. /**
  70927. * Returns the wireframe mode
  70928. */
  70929. static readonly MATERIAL_WireFrameFillMode: number;
  70930. /**
  70931. * Returns the point fill mode
  70932. */
  70933. static readonly MATERIAL_PointFillMode: number;
  70934. /**
  70935. * Returns the point list draw mode
  70936. */
  70937. static readonly MATERIAL_PointListDrawMode: number;
  70938. /**
  70939. * Returns the line list draw mode
  70940. */
  70941. static readonly MATERIAL_LineListDrawMode: number;
  70942. /**
  70943. * Returns the line loop draw mode
  70944. */
  70945. static readonly MATERIAL_LineLoopDrawMode: number;
  70946. /**
  70947. * Returns the line strip draw mode
  70948. */
  70949. static readonly MATERIAL_LineStripDrawMode: number;
  70950. /**
  70951. * Returns the triangle strip draw mode
  70952. */
  70953. static readonly MATERIAL_TriangleStripDrawMode: number;
  70954. /**
  70955. * Returns the triangle fan draw mode
  70956. */
  70957. static readonly MATERIAL_TriangleFanDrawMode: number;
  70958. /**
  70959. * Stores the clock-wise side orientation
  70960. */
  70961. static readonly MATERIAL_ClockWiseSideOrientation: number;
  70962. /**
  70963. * Stores the counter clock-wise side orientation
  70964. */
  70965. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  70966. /**
  70967. * Nothing
  70968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70969. */
  70970. static readonly ACTION_NothingTrigger: number;
  70971. /**
  70972. * On pick
  70973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70974. */
  70975. static readonly ACTION_OnPickTrigger: number;
  70976. /**
  70977. * On left pick
  70978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70979. */
  70980. static readonly ACTION_OnLeftPickTrigger: number;
  70981. /**
  70982. * On right pick
  70983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70984. */
  70985. static readonly ACTION_OnRightPickTrigger: number;
  70986. /**
  70987. * On center pick
  70988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70989. */
  70990. static readonly ACTION_OnCenterPickTrigger: number;
  70991. /**
  70992. * On pick down
  70993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70994. */
  70995. static readonly ACTION_OnPickDownTrigger: number;
  70996. /**
  70997. * On double pick
  70998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70999. */
  71000. static readonly ACTION_OnDoublePickTrigger: number;
  71001. /**
  71002. * On pick up
  71003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71004. */
  71005. static readonly ACTION_OnPickUpTrigger: number;
  71006. /**
  71007. * On pick out.
  71008. * This trigger will only be raised if you also declared a OnPickDown
  71009. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71010. */
  71011. static readonly ACTION_OnPickOutTrigger: number;
  71012. /**
  71013. * On long press
  71014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71015. */
  71016. static readonly ACTION_OnLongPressTrigger: number;
  71017. /**
  71018. * On pointer over
  71019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71020. */
  71021. static readonly ACTION_OnPointerOverTrigger: number;
  71022. /**
  71023. * On pointer out
  71024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71025. */
  71026. static readonly ACTION_OnPointerOutTrigger: number;
  71027. /**
  71028. * On every frame
  71029. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71030. */
  71031. static readonly ACTION_OnEveryFrameTrigger: number;
  71032. /**
  71033. * On intersection enter
  71034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71035. */
  71036. static readonly ACTION_OnIntersectionEnterTrigger: number;
  71037. /**
  71038. * On intersection exit
  71039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71040. */
  71041. static readonly ACTION_OnIntersectionExitTrigger: number;
  71042. /**
  71043. * On key down
  71044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71045. */
  71046. static readonly ACTION_OnKeyDownTrigger: number;
  71047. /**
  71048. * On key up
  71049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71050. */
  71051. static readonly ACTION_OnKeyUpTrigger: number;
  71052. /**
  71053. * Billboard mode will only apply to Y axis
  71054. */
  71055. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  71056. /**
  71057. * Billboard mode will apply to all axes
  71058. */
  71059. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  71060. /**
  71061. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71062. */
  71063. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  71064. /**
  71065. * Gets or sets base Assets URL
  71066. */
  71067. static PARTICLES_BaseAssetsUrl: string;
  71068. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  71069. * Test order :
  71070. * Is the bounding sphere outside the frustum ?
  71071. * If not, are the bounding box vertices outside the frustum ?
  71072. * It not, then the cullable object is in the frustum.
  71073. */
  71074. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  71075. /** Culling strategy : Bounding Sphere Only.
  71076. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  71077. * It's also less accurate than the standard because some not visible objects can still be selected.
  71078. * Test : is the bounding sphere outside the frustum ?
  71079. * If not, then the cullable object is in the frustum.
  71080. */
  71081. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  71082. /** Culling strategy : Optimistic Inclusion.
  71083. * This in an inclusion test first, then the standard exclusion test.
  71084. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  71085. * 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.
  71086. * Anyway, it's as accurate as the standard strategy.
  71087. * Test :
  71088. * Is the cullable object bounding sphere center in the frustum ?
  71089. * If not, apply the default culling strategy.
  71090. */
  71091. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  71092. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  71093. * This in an inclusion test first, then the bounding sphere only exclusion test.
  71094. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  71095. * 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.
  71096. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  71097. * Test :
  71098. * Is the cullable object bounding sphere center in the frustum ?
  71099. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  71100. */
  71101. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  71102. /**
  71103. * No logging while loading
  71104. */
  71105. static readonly SCENELOADER_NO_LOGGING: number;
  71106. /**
  71107. * Minimal logging while loading
  71108. */
  71109. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  71110. /**
  71111. * Summary logging while loading
  71112. */
  71113. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  71114. /**
  71115. * Detailled logging while loading
  71116. */
  71117. static readonly SCENELOADER_DETAILED_LOGGING: number;
  71118. }
  71119. }
  71120. declare module BABYLON {
  71121. /**
  71122. * This represents the required contract to create a new type of texture loader.
  71123. */
  71124. export interface IInternalTextureLoader {
  71125. /**
  71126. * Defines wether the loader supports cascade loading the different faces.
  71127. */
  71128. supportCascades: boolean;
  71129. /**
  71130. * This returns if the loader support the current file information.
  71131. * @param extension defines the file extension of the file being loaded
  71132. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71133. * @param fallback defines the fallback internal texture if any
  71134. * @param isBase64 defines whether the texture is encoded as a base64
  71135. * @param isBuffer defines whether the texture data are stored as a buffer
  71136. * @returns true if the loader can load the specified file
  71137. */
  71138. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71139. /**
  71140. * Transform the url before loading if required.
  71141. * @param rootUrl the url of the texture
  71142. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71143. * @returns the transformed texture
  71144. */
  71145. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71146. /**
  71147. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71148. * @param rootUrl the url of the texture
  71149. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71150. * @returns the fallback texture
  71151. */
  71152. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71153. /**
  71154. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71155. * @param data contains the texture data
  71156. * @param texture defines the BabylonJS internal texture
  71157. * @param createPolynomials will be true if polynomials have been requested
  71158. * @param onLoad defines the callback to trigger once the texture is ready
  71159. * @param onError defines the callback to trigger in case of error
  71160. */
  71161. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71162. /**
  71163. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71164. * @param data contains the texture data
  71165. * @param texture defines the BabylonJS internal texture
  71166. * @param callback defines the method to call once ready to upload
  71167. */
  71168. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71169. }
  71170. }
  71171. declare module BABYLON {
  71172. /**
  71173. * Class used to store and describe the pipeline context associated with an effect
  71174. */
  71175. export interface IPipelineContext {
  71176. /**
  71177. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  71178. */
  71179. isAsync: boolean;
  71180. /**
  71181. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  71182. */
  71183. isReady: boolean;
  71184. /** @hidden */
  71185. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  71186. }
  71187. }
  71188. declare module BABYLON {
  71189. /**
  71190. * Class used to store gfx data (like WebGLBuffer)
  71191. */
  71192. export class DataBuffer {
  71193. /**
  71194. * Gets or sets the number of objects referencing this buffer
  71195. */
  71196. references: number;
  71197. /** Gets or sets the size of the underlying buffer */
  71198. capacity: number;
  71199. /**
  71200. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  71201. */
  71202. is32Bits: boolean;
  71203. /**
  71204. * Gets the underlying buffer
  71205. */
  71206. readonly underlyingResource: any;
  71207. }
  71208. }
  71209. declare module BABYLON {
  71210. /** @hidden */
  71211. export interface IShaderProcessor {
  71212. attributeProcessor?: (attribute: string) => string;
  71213. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  71214. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  71215. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  71216. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  71217. lineProcessor?: (line: string, isFragment: boolean) => string;
  71218. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71219. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71220. }
  71221. }
  71222. declare module BABYLON {
  71223. /** @hidden */
  71224. export interface ProcessingOptions {
  71225. defines: string[];
  71226. indexParameters: any;
  71227. isFragment: boolean;
  71228. shouldUseHighPrecisionShader: boolean;
  71229. supportsUniformBuffers: boolean;
  71230. shadersRepository: string;
  71231. includesShadersStore: {
  71232. [key: string]: string;
  71233. };
  71234. processor?: IShaderProcessor;
  71235. version: string;
  71236. platformName: string;
  71237. lookForClosingBracketForUniformBuffer?: boolean;
  71238. }
  71239. }
  71240. declare module BABYLON {
  71241. /**
  71242. * Helper to manipulate strings
  71243. */
  71244. export class StringTools {
  71245. /**
  71246. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  71247. * @param str Source string
  71248. * @param suffix Suffix to search for in the source string
  71249. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71250. */
  71251. static EndsWith(str: string, suffix: string): boolean;
  71252. /**
  71253. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  71254. * @param str Source string
  71255. * @param suffix Suffix to search for in the source string
  71256. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71257. */
  71258. static StartsWith(str: string, suffix: string): boolean;
  71259. }
  71260. }
  71261. declare module BABYLON {
  71262. /** @hidden */
  71263. export class ShaderCodeNode {
  71264. line: string;
  71265. children: ShaderCodeNode[];
  71266. additionalDefineKey?: string;
  71267. additionalDefineValue?: string;
  71268. isValid(preprocessors: {
  71269. [key: string]: string;
  71270. }): boolean;
  71271. process(preprocessors: {
  71272. [key: string]: string;
  71273. }, options: ProcessingOptions): string;
  71274. }
  71275. }
  71276. declare module BABYLON {
  71277. /** @hidden */
  71278. export class ShaderCodeCursor {
  71279. private _lines;
  71280. lineIndex: number;
  71281. readonly currentLine: string;
  71282. readonly canRead: boolean;
  71283. lines: string[];
  71284. }
  71285. }
  71286. declare module BABYLON {
  71287. /** @hidden */
  71288. export class ShaderCodeConditionNode extends ShaderCodeNode {
  71289. process(preprocessors: {
  71290. [key: string]: string;
  71291. }, options: ProcessingOptions): string;
  71292. }
  71293. }
  71294. declare module BABYLON {
  71295. /** @hidden */
  71296. export class ShaderDefineExpression {
  71297. isTrue(preprocessors: {
  71298. [key: string]: string;
  71299. }): boolean;
  71300. }
  71301. }
  71302. declare module BABYLON {
  71303. /** @hidden */
  71304. export class ShaderCodeTestNode extends ShaderCodeNode {
  71305. testExpression: ShaderDefineExpression;
  71306. isValid(preprocessors: {
  71307. [key: string]: string;
  71308. }): boolean;
  71309. }
  71310. }
  71311. declare module BABYLON {
  71312. /** @hidden */
  71313. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  71314. define: string;
  71315. not: boolean;
  71316. constructor(define: string, not?: boolean);
  71317. isTrue(preprocessors: {
  71318. [key: string]: string;
  71319. }): boolean;
  71320. }
  71321. }
  71322. declare module BABYLON {
  71323. /** @hidden */
  71324. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  71325. leftOperand: ShaderDefineExpression;
  71326. rightOperand: ShaderDefineExpression;
  71327. isTrue(preprocessors: {
  71328. [key: string]: string;
  71329. }): boolean;
  71330. }
  71331. }
  71332. declare module BABYLON {
  71333. /** @hidden */
  71334. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  71335. leftOperand: ShaderDefineExpression;
  71336. rightOperand: ShaderDefineExpression;
  71337. isTrue(preprocessors: {
  71338. [key: string]: string;
  71339. }): boolean;
  71340. }
  71341. }
  71342. declare module BABYLON {
  71343. /** @hidden */
  71344. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  71345. define: string;
  71346. operand: string;
  71347. testValue: string;
  71348. constructor(define: string, operand: string, testValue: string);
  71349. isTrue(preprocessors: {
  71350. [key: string]: string;
  71351. }): boolean;
  71352. }
  71353. }
  71354. declare module BABYLON {
  71355. /**
  71356. * @ignore
  71357. * Application error to support additional information when loading a file
  71358. */
  71359. export class LoadFileError extends Error {
  71360. /** defines the optional web request */
  71361. request?: WebRequest | undefined;
  71362. private static _setPrototypeOf;
  71363. /**
  71364. * Creates a new LoadFileError
  71365. * @param message defines the message of the error
  71366. * @param request defines the optional web request
  71367. */
  71368. constructor(message: string,
  71369. /** defines the optional web request */
  71370. request?: WebRequest | undefined);
  71371. }
  71372. }
  71373. declare module BABYLON {
  71374. /**
  71375. * Class used to enable access to offline support
  71376. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71377. */
  71378. export interface IOfflineProvider {
  71379. /**
  71380. * Gets a boolean indicating if scene must be saved in the database
  71381. */
  71382. enableSceneOffline: boolean;
  71383. /**
  71384. * Gets a boolean indicating if textures must be saved in the database
  71385. */
  71386. enableTexturesOffline: boolean;
  71387. /**
  71388. * Open the offline support and make it available
  71389. * @param successCallback defines the callback to call on success
  71390. * @param errorCallback defines the callback to call on error
  71391. */
  71392. open(successCallback: () => void, errorCallback: () => void): void;
  71393. /**
  71394. * Loads an image from the offline support
  71395. * @param url defines the url to load from
  71396. * @param image defines the target DOM image
  71397. */
  71398. loadImage(url: string, image: HTMLImageElement): void;
  71399. /**
  71400. * Loads a file from offline support
  71401. * @param url defines the URL to load from
  71402. * @param sceneLoaded defines a callback to call on success
  71403. * @param progressCallBack defines a callback to call when progress changed
  71404. * @param errorCallback defines a callback to call on error
  71405. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71406. */
  71407. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71408. }
  71409. }
  71410. declare module BABYLON {
  71411. /**
  71412. * Class used to help managing file picking and drag'n'drop
  71413. * File Storage
  71414. */
  71415. export class FilesInputStore {
  71416. /**
  71417. * List of files ready to be loaded
  71418. */
  71419. static FilesToLoad: {
  71420. [key: string]: File;
  71421. };
  71422. }
  71423. }
  71424. declare module BABYLON {
  71425. /**
  71426. * Class used to define a retry strategy when error happens while loading assets
  71427. */
  71428. export class RetryStrategy {
  71429. /**
  71430. * Function used to defines an exponential back off strategy
  71431. * @param maxRetries defines the maximum number of retries (3 by default)
  71432. * @param baseInterval defines the interval between retries
  71433. * @returns the strategy function to use
  71434. */
  71435. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  71436. }
  71437. }
  71438. declare module BABYLON {
  71439. /**
  71440. * @hidden
  71441. */
  71442. export class FileTools {
  71443. /**
  71444. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  71445. */
  71446. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  71447. /**
  71448. * Gets or sets the base URL to use to load assets
  71449. */
  71450. static BaseUrl: string;
  71451. /**
  71452. * Default behaviour for cors in the application.
  71453. * It can be a string if the expected behavior is identical in the entire app.
  71454. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  71455. */
  71456. static CorsBehavior: string | ((url: string | string[]) => string);
  71457. /**
  71458. * Gets or sets a function used to pre-process url before using them to load assets
  71459. */
  71460. static PreprocessUrl: (url: string) => string;
  71461. /**
  71462. * Removes unwanted characters from an url
  71463. * @param url defines the url to clean
  71464. * @returns the cleaned url
  71465. */
  71466. private static _CleanUrl;
  71467. /**
  71468. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  71469. * @param url define the url we are trying
  71470. * @param element define the dom element where to configure the cors policy
  71471. */
  71472. static SetCorsBehavior(url: string | string[], element: {
  71473. crossOrigin: string | null;
  71474. }): void;
  71475. /**
  71476. * Loads an image as an HTMLImageElement.
  71477. * @param input url string, ArrayBuffer, or Blob to load
  71478. * @param onLoad callback called when the image successfully loads
  71479. * @param onError callback called when the image fails to load
  71480. * @param offlineProvider offline provider for caching
  71481. * @returns the HTMLImageElement of the loaded image
  71482. */
  71483. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  71484. /**
  71485. * Loads a file
  71486. * @param fileToLoad defines the file to load
  71487. * @param callback defines the callback to call when data is loaded
  71488. * @param progressCallBack defines the callback to call during loading process
  71489. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  71490. * @returns a file request object
  71491. */
  71492. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  71493. /**
  71494. * Loads a file
  71495. * @param url url string, ArrayBuffer, or Blob to load
  71496. * @param onSuccess callback called when the file successfully loads
  71497. * @param onProgress callback called while file is loading (if the server supports this mode)
  71498. * @param offlineProvider defines the offline provider for caching
  71499. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  71500. * @param onError callback called when the file fails to load
  71501. * @returns a file request object
  71502. */
  71503. 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;
  71504. /**
  71505. * Checks if the loaded document was accessed via `file:`-Protocol.
  71506. * @returns boolean
  71507. */
  71508. static IsFileURL(): boolean;
  71509. }
  71510. }
  71511. declare module BABYLON {
  71512. /** @hidden */
  71513. export class ShaderProcessor {
  71514. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  71515. private static _ProcessPrecision;
  71516. private static _ExtractOperation;
  71517. private static _BuildSubExpression;
  71518. private static _BuildExpression;
  71519. private static _MoveCursorWithinIf;
  71520. private static _MoveCursor;
  71521. private static _EvaluatePreProcessors;
  71522. private static _PreparePreProcessors;
  71523. private static _ProcessShaderConversion;
  71524. private static _ProcessIncludes;
  71525. }
  71526. }
  71527. declare module BABYLON {
  71528. /**
  71529. * Interface used to define common properties for effect fallbacks
  71530. */
  71531. export interface IEffectFallbacks {
  71532. /**
  71533. * Removes the defines that should be removed when falling back.
  71534. * @param currentDefines defines the current define statements for the shader.
  71535. * @param effect defines the current effect we try to compile
  71536. * @returns The resulting defines with defines of the current rank removed.
  71537. */
  71538. reduce(currentDefines: string, effect: Effect): string;
  71539. /**
  71540. * Removes the fallback from the bound mesh.
  71541. */
  71542. unBindMesh(): void;
  71543. /**
  71544. * Checks to see if more fallbacks are still availible.
  71545. */
  71546. hasMoreFallbacks: boolean;
  71547. }
  71548. }
  71549. declare module BABYLON {
  71550. /**
  71551. * Class used to evalaute queries containing `and` and `or` operators
  71552. */
  71553. export class AndOrNotEvaluator {
  71554. /**
  71555. * Evaluate a query
  71556. * @param query defines the query to evaluate
  71557. * @param evaluateCallback defines the callback used to filter result
  71558. * @returns true if the query matches
  71559. */
  71560. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71561. private static _HandleParenthesisContent;
  71562. private static _SimplifyNegation;
  71563. }
  71564. }
  71565. declare module BABYLON {
  71566. /**
  71567. * Class used to store custom tags
  71568. */
  71569. export class Tags {
  71570. /**
  71571. * Adds support for tags on the given object
  71572. * @param obj defines the object to use
  71573. */
  71574. static EnableFor(obj: any): void;
  71575. /**
  71576. * Removes tags support
  71577. * @param obj defines the object to use
  71578. */
  71579. static DisableFor(obj: any): void;
  71580. /**
  71581. * Gets a boolean indicating if the given object has tags
  71582. * @param obj defines the object to use
  71583. * @returns a boolean
  71584. */
  71585. static HasTags(obj: any): boolean;
  71586. /**
  71587. * Gets the tags available on a given object
  71588. * @param obj defines the object to use
  71589. * @param asString defines if the tags must be returned as a string instead of an array of strings
  71590. * @returns the tags
  71591. */
  71592. static GetTags(obj: any, asString?: boolean): any;
  71593. /**
  71594. * Adds tags to an object
  71595. * @param obj defines the object to use
  71596. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  71597. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  71598. */
  71599. static AddTagsTo(obj: any, tagsString: string): void;
  71600. /**
  71601. * @hidden
  71602. */
  71603. static _AddTagTo(obj: any, tag: string): void;
  71604. /**
  71605. * Removes specific tags from a specific object
  71606. * @param obj defines the object to use
  71607. * @param tagsString defines the tags to remove
  71608. */
  71609. static RemoveTagsFrom(obj: any, tagsString: string): void;
  71610. /**
  71611. * @hidden
  71612. */
  71613. static _RemoveTagFrom(obj: any, tag: string): void;
  71614. /**
  71615. * Defines if tags hosted on an object match a given query
  71616. * @param obj defines the object to use
  71617. * @param tagsQuery defines the tag query
  71618. * @returns a boolean
  71619. */
  71620. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71621. }
  71622. }
  71623. declare module BABYLON {
  71624. /**
  71625. * Defines potential orientation for back face culling
  71626. */
  71627. export enum Orientation {
  71628. /**
  71629. * Clockwise
  71630. */
  71631. CW = 0,
  71632. /** Counter clockwise */
  71633. CCW = 1
  71634. }
  71635. /** Class used to represent a Bezier curve */
  71636. export class BezierCurve {
  71637. /**
  71638. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71639. * @param t defines the time
  71640. * @param x1 defines the left coordinate on X axis
  71641. * @param y1 defines the left coordinate on Y axis
  71642. * @param x2 defines the right coordinate on X axis
  71643. * @param y2 defines the right coordinate on Y axis
  71644. * @returns the interpolated value
  71645. */
  71646. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71647. }
  71648. /**
  71649. * Defines angle representation
  71650. */
  71651. export class Angle {
  71652. private _radians;
  71653. /**
  71654. * Creates an Angle object of "radians" radians (float).
  71655. * @param radians the angle in radians
  71656. */
  71657. constructor(radians: number);
  71658. /**
  71659. * Get value in degrees
  71660. * @returns the Angle value in degrees (float)
  71661. */
  71662. degrees(): number;
  71663. /**
  71664. * Get value in radians
  71665. * @returns the Angle value in radians (float)
  71666. */
  71667. radians(): number;
  71668. /**
  71669. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71670. * @param a defines first vector
  71671. * @param b defines second vector
  71672. * @returns a new Angle
  71673. */
  71674. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71675. /**
  71676. * Gets a new Angle object from the given float in radians
  71677. * @param radians defines the angle value in radians
  71678. * @returns a new Angle
  71679. */
  71680. static FromRadians(radians: number): Angle;
  71681. /**
  71682. * Gets a new Angle object from the given float in degrees
  71683. * @param degrees defines the angle value in degrees
  71684. * @returns a new Angle
  71685. */
  71686. static FromDegrees(degrees: number): Angle;
  71687. }
  71688. /**
  71689. * This represents an arc in a 2d space.
  71690. */
  71691. export class Arc2 {
  71692. /** Defines the start point of the arc */
  71693. startPoint: Vector2;
  71694. /** Defines the mid point of the arc */
  71695. midPoint: Vector2;
  71696. /** Defines the end point of the arc */
  71697. endPoint: Vector2;
  71698. /**
  71699. * Defines the center point of the arc.
  71700. */
  71701. centerPoint: Vector2;
  71702. /**
  71703. * Defines the radius of the arc.
  71704. */
  71705. radius: number;
  71706. /**
  71707. * Defines the angle of the arc (from mid point to end point).
  71708. */
  71709. angle: Angle;
  71710. /**
  71711. * Defines the start angle of the arc (from start point to middle point).
  71712. */
  71713. startAngle: Angle;
  71714. /**
  71715. * Defines the orientation of the arc (clock wise/counter clock wise).
  71716. */
  71717. orientation: Orientation;
  71718. /**
  71719. * Creates an Arc object from the three given points : start, middle and end.
  71720. * @param startPoint Defines the start point of the arc
  71721. * @param midPoint Defines the midlle point of the arc
  71722. * @param endPoint Defines the end point of the arc
  71723. */
  71724. constructor(
  71725. /** Defines the start point of the arc */
  71726. startPoint: Vector2,
  71727. /** Defines the mid point of the arc */
  71728. midPoint: Vector2,
  71729. /** Defines the end point of the arc */
  71730. endPoint: Vector2);
  71731. }
  71732. /**
  71733. * Represents a 2D path made up of multiple 2D points
  71734. */
  71735. export class Path2 {
  71736. private _points;
  71737. private _length;
  71738. /**
  71739. * If the path start and end point are the same
  71740. */
  71741. closed: boolean;
  71742. /**
  71743. * Creates a Path2 object from the starting 2D coordinates x and y.
  71744. * @param x the starting points x value
  71745. * @param y the starting points y value
  71746. */
  71747. constructor(x: number, y: number);
  71748. /**
  71749. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71750. * @param x the added points x value
  71751. * @param y the added points y value
  71752. * @returns the updated Path2.
  71753. */
  71754. addLineTo(x: number, y: number): Path2;
  71755. /**
  71756. * 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.
  71757. * @param midX middle point x value
  71758. * @param midY middle point y value
  71759. * @param endX end point x value
  71760. * @param endY end point y value
  71761. * @param numberOfSegments (default: 36)
  71762. * @returns the updated Path2.
  71763. */
  71764. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71765. /**
  71766. * Closes the Path2.
  71767. * @returns the Path2.
  71768. */
  71769. close(): Path2;
  71770. /**
  71771. * Gets the sum of the distance between each sequential point in the path
  71772. * @returns the Path2 total length (float).
  71773. */
  71774. length(): number;
  71775. /**
  71776. * Gets the points which construct the path
  71777. * @returns the Path2 internal array of points.
  71778. */
  71779. getPoints(): Vector2[];
  71780. /**
  71781. * Retreives the point at the distance aways from the starting point
  71782. * @param normalizedLengthPosition the length along the path to retreive the point from
  71783. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71784. */
  71785. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71786. /**
  71787. * Creates a new path starting from an x and y position
  71788. * @param x starting x value
  71789. * @param y starting y value
  71790. * @returns a new Path2 starting at the coordinates (x, y).
  71791. */
  71792. static StartingAt(x: number, y: number): Path2;
  71793. }
  71794. /**
  71795. * Represents a 3D path made up of multiple 3D points
  71796. */
  71797. export class Path3D {
  71798. /**
  71799. * an array of Vector3, the curve axis of the Path3D
  71800. */
  71801. path: Vector3[];
  71802. private _curve;
  71803. private _distances;
  71804. private _tangents;
  71805. private _normals;
  71806. private _binormals;
  71807. private _raw;
  71808. /**
  71809. * new Path3D(path, normal, raw)
  71810. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71811. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71812. * @param path an array of Vector3, the curve axis of the Path3D
  71813. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71814. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71815. */
  71816. constructor(
  71817. /**
  71818. * an array of Vector3, the curve axis of the Path3D
  71819. */
  71820. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71821. /**
  71822. * Returns the Path3D array of successive Vector3 designing its curve.
  71823. * @returns the Path3D array of successive Vector3 designing its curve.
  71824. */
  71825. getCurve(): Vector3[];
  71826. /**
  71827. * Returns an array populated with tangent vectors on each Path3D curve point.
  71828. * @returns an array populated with tangent vectors on each Path3D curve point.
  71829. */
  71830. getTangents(): Vector3[];
  71831. /**
  71832. * Returns an array populated with normal vectors on each Path3D curve point.
  71833. * @returns an array populated with normal vectors on each Path3D curve point.
  71834. */
  71835. getNormals(): Vector3[];
  71836. /**
  71837. * Returns an array populated with binormal vectors on each Path3D curve point.
  71838. * @returns an array populated with binormal vectors on each Path3D curve point.
  71839. */
  71840. getBinormals(): Vector3[];
  71841. /**
  71842. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71843. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71844. */
  71845. getDistances(): number[];
  71846. /**
  71847. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71848. * @param path path which all values are copied into the curves points
  71849. * @param firstNormal which should be projected onto the curve
  71850. * @returns the same object updated.
  71851. */
  71852. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71853. private _compute;
  71854. private _getFirstNonNullVector;
  71855. private _getLastNonNullVector;
  71856. private _normalVector;
  71857. }
  71858. /**
  71859. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71860. * A Curve3 is designed from a series of successive Vector3.
  71861. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71862. */
  71863. export class Curve3 {
  71864. private _points;
  71865. private _length;
  71866. /**
  71867. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  71868. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  71869. * @param v1 (Vector3) the control point
  71870. * @param v2 (Vector3) the end point of the Quadratic Bezier
  71871. * @param nbPoints (integer) the wanted number of points in the curve
  71872. * @returns the created Curve3
  71873. */
  71874. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71875. /**
  71876. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  71877. * @param v0 (Vector3) the origin point of the Cubic Bezier
  71878. * @param v1 (Vector3) the first control point
  71879. * @param v2 (Vector3) the second control point
  71880. * @param v3 (Vector3) the end point of the Cubic Bezier
  71881. * @param nbPoints (integer) the wanted number of points in the curve
  71882. * @returns the created Curve3
  71883. */
  71884. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71885. /**
  71886. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71887. * @param p1 (Vector3) the origin point of the Hermite Spline
  71888. * @param t1 (Vector3) the tangent vector at the origin point
  71889. * @param p2 (Vector3) the end point of the Hermite Spline
  71890. * @param t2 (Vector3) the tangent vector at the end point
  71891. * @param nbPoints (integer) the wanted number of points in the curve
  71892. * @returns the created Curve3
  71893. */
  71894. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71895. /**
  71896. * Returns a Curve3 object along a CatmullRom Spline curve :
  71897. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71898. * @param nbPoints (integer) the wanted number of points between each curve control points
  71899. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71900. * @returns the created Curve3
  71901. */
  71902. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71903. /**
  71904. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71905. * A Curve3 is designed from a series of successive Vector3.
  71906. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71907. * @param points points which make up the curve
  71908. */
  71909. constructor(points: Vector3[]);
  71910. /**
  71911. * @returns the Curve3 stored array of successive Vector3
  71912. */
  71913. getPoints(): Vector3[];
  71914. /**
  71915. * @returns the computed length (float) of the curve.
  71916. */
  71917. length(): number;
  71918. /**
  71919. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71920. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71921. * curveA and curveB keep unchanged.
  71922. * @param curve the curve to continue from this curve
  71923. * @returns the newly constructed curve
  71924. */
  71925. continue(curve: DeepImmutable<Curve3>): Curve3;
  71926. private _computeLength;
  71927. }
  71928. }
  71929. declare module BABYLON {
  71930. /**
  71931. * This represents the main contract an easing function should follow.
  71932. * Easing functions are used throughout the animation system.
  71933. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71934. */
  71935. export interface IEasingFunction {
  71936. /**
  71937. * Given an input gradient between 0 and 1, this returns the corrseponding value
  71938. * of the easing function.
  71939. * The link below provides some of the most common examples of easing functions.
  71940. * @see https://easings.net/
  71941. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71942. * @returns the corresponding value on the curve defined by the easing function
  71943. */
  71944. ease(gradient: number): number;
  71945. }
  71946. /**
  71947. * Base class used for every default easing function.
  71948. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71949. */
  71950. export class EasingFunction implements IEasingFunction {
  71951. /**
  71952. * Interpolation follows the mathematical formula associated with the easing function.
  71953. */
  71954. static readonly EASINGMODE_EASEIN: number;
  71955. /**
  71956. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  71957. */
  71958. static readonly EASINGMODE_EASEOUT: number;
  71959. /**
  71960. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  71961. */
  71962. static readonly EASINGMODE_EASEINOUT: number;
  71963. private _easingMode;
  71964. /**
  71965. * Sets the easing mode of the current function.
  71966. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71967. */
  71968. setEasingMode(easingMode: number): void;
  71969. /**
  71970. * Gets the current easing mode.
  71971. * @returns the easing mode
  71972. */
  71973. getEasingMode(): number;
  71974. /**
  71975. * @hidden
  71976. */
  71977. easeInCore(gradient: number): number;
  71978. /**
  71979. * Given an input gradient between 0 and 1, this returns the corresponding value
  71980. * of the easing function.
  71981. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71982. * @returns the corresponding value on the curve defined by the easing function
  71983. */
  71984. ease(gradient: number): number;
  71985. }
  71986. /**
  71987. * Easing function with a circle shape (see link below).
  71988. * @see https://easings.net/#easeInCirc
  71989. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71990. */
  71991. export class CircleEase extends EasingFunction implements IEasingFunction {
  71992. /** @hidden */
  71993. easeInCore(gradient: number): number;
  71994. }
  71995. /**
  71996. * Easing function with a ease back shape (see link below).
  71997. * @see https://easings.net/#easeInBack
  71998. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71999. */
  72000. export class BackEase extends EasingFunction implements IEasingFunction {
  72001. /** Defines the amplitude of the function */
  72002. amplitude: number;
  72003. /**
  72004. * Instantiates a back ease easing
  72005. * @see https://easings.net/#easeInBack
  72006. * @param amplitude Defines the amplitude of the function
  72007. */
  72008. constructor(
  72009. /** Defines the amplitude of the function */
  72010. amplitude?: number);
  72011. /** @hidden */
  72012. easeInCore(gradient: number): number;
  72013. }
  72014. /**
  72015. * Easing function with a bouncing shape (see link below).
  72016. * @see https://easings.net/#easeInBounce
  72017. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72018. */
  72019. export class BounceEase extends EasingFunction implements IEasingFunction {
  72020. /** Defines the number of bounces */
  72021. bounces: number;
  72022. /** Defines the amplitude of the bounce */
  72023. bounciness: number;
  72024. /**
  72025. * Instantiates a bounce easing
  72026. * @see https://easings.net/#easeInBounce
  72027. * @param bounces Defines the number of bounces
  72028. * @param bounciness Defines the amplitude of the bounce
  72029. */
  72030. constructor(
  72031. /** Defines the number of bounces */
  72032. bounces?: number,
  72033. /** Defines the amplitude of the bounce */
  72034. bounciness?: number);
  72035. /** @hidden */
  72036. easeInCore(gradient: number): number;
  72037. }
  72038. /**
  72039. * Easing function with a power of 3 shape (see link below).
  72040. * @see https://easings.net/#easeInCubic
  72041. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72042. */
  72043. export class CubicEase extends EasingFunction implements IEasingFunction {
  72044. /** @hidden */
  72045. easeInCore(gradient: number): number;
  72046. }
  72047. /**
  72048. * Easing function with an elastic shape (see link below).
  72049. * @see https://easings.net/#easeInElastic
  72050. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72051. */
  72052. export class ElasticEase extends EasingFunction implements IEasingFunction {
  72053. /** Defines the number of oscillations*/
  72054. oscillations: number;
  72055. /** Defines the amplitude of the oscillations*/
  72056. springiness: number;
  72057. /**
  72058. * Instantiates an elastic easing function
  72059. * @see https://easings.net/#easeInElastic
  72060. * @param oscillations Defines the number of oscillations
  72061. * @param springiness Defines the amplitude of the oscillations
  72062. */
  72063. constructor(
  72064. /** Defines the number of oscillations*/
  72065. oscillations?: number,
  72066. /** Defines the amplitude of the oscillations*/
  72067. springiness?: number);
  72068. /** @hidden */
  72069. easeInCore(gradient: number): number;
  72070. }
  72071. /**
  72072. * Easing function with an exponential shape (see link below).
  72073. * @see https://easings.net/#easeInExpo
  72074. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72075. */
  72076. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72077. /** Defines the exponent of the function */
  72078. exponent: number;
  72079. /**
  72080. * Instantiates an exponential easing function
  72081. * @see https://easings.net/#easeInExpo
  72082. * @param exponent Defines the exponent of the function
  72083. */
  72084. constructor(
  72085. /** Defines the exponent of the function */
  72086. exponent?: number);
  72087. /** @hidden */
  72088. easeInCore(gradient: number): number;
  72089. }
  72090. /**
  72091. * Easing function with a power shape (see link below).
  72092. * @see https://easings.net/#easeInQuad
  72093. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72094. */
  72095. export class PowerEase extends EasingFunction implements IEasingFunction {
  72096. /** Defines the power of the function */
  72097. power: number;
  72098. /**
  72099. * Instantiates an power base easing function
  72100. * @see https://easings.net/#easeInQuad
  72101. * @param power Defines the power of the function
  72102. */
  72103. constructor(
  72104. /** Defines the power of the function */
  72105. power?: number);
  72106. /** @hidden */
  72107. easeInCore(gradient: number): number;
  72108. }
  72109. /**
  72110. * Easing function with a power of 2 shape (see link below).
  72111. * @see https://easings.net/#easeInQuad
  72112. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72113. */
  72114. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72115. /** @hidden */
  72116. easeInCore(gradient: number): number;
  72117. }
  72118. /**
  72119. * Easing function with a power of 4 shape (see link below).
  72120. * @see https://easings.net/#easeInQuart
  72121. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72122. */
  72123. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72124. /** @hidden */
  72125. easeInCore(gradient: number): number;
  72126. }
  72127. /**
  72128. * Easing function with a power of 5 shape (see link below).
  72129. * @see https://easings.net/#easeInQuint
  72130. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72131. */
  72132. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72133. /** @hidden */
  72134. easeInCore(gradient: number): number;
  72135. }
  72136. /**
  72137. * Easing function with a sin shape (see link below).
  72138. * @see https://easings.net/#easeInSine
  72139. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72140. */
  72141. export class SineEase extends EasingFunction implements IEasingFunction {
  72142. /** @hidden */
  72143. easeInCore(gradient: number): number;
  72144. }
  72145. /**
  72146. * Easing function with a bezier shape (see link below).
  72147. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72148. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72149. */
  72150. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72151. /** Defines the x component of the start tangent in the bezier curve */
  72152. x1: number;
  72153. /** Defines the y component of the start tangent in the bezier curve */
  72154. y1: number;
  72155. /** Defines the x component of the end tangent in the bezier curve */
  72156. x2: number;
  72157. /** Defines the y component of the end tangent in the bezier curve */
  72158. y2: number;
  72159. /**
  72160. * Instantiates a bezier function
  72161. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72162. * @param x1 Defines the x component of the start tangent in the bezier curve
  72163. * @param y1 Defines the y component of the start tangent in the bezier curve
  72164. * @param x2 Defines the x component of the end tangent in the bezier curve
  72165. * @param y2 Defines the y component of the end tangent in the bezier curve
  72166. */
  72167. constructor(
  72168. /** Defines the x component of the start tangent in the bezier curve */
  72169. x1?: number,
  72170. /** Defines the y component of the start tangent in the bezier curve */
  72171. y1?: number,
  72172. /** Defines the x component of the end tangent in the bezier curve */
  72173. x2?: number,
  72174. /** Defines the y component of the end tangent in the bezier curve */
  72175. y2?: number);
  72176. /** @hidden */
  72177. easeInCore(gradient: number): number;
  72178. }
  72179. }
  72180. declare module BABYLON {
  72181. /**
  72182. * Defines an interface which represents an animation key frame
  72183. */
  72184. export interface IAnimationKey {
  72185. /**
  72186. * Frame of the key frame
  72187. */
  72188. frame: number;
  72189. /**
  72190. * Value at the specifies key frame
  72191. */
  72192. value: any;
  72193. /**
  72194. * The input tangent for the cubic hermite spline
  72195. */
  72196. inTangent?: any;
  72197. /**
  72198. * The output tangent for the cubic hermite spline
  72199. */
  72200. outTangent?: any;
  72201. /**
  72202. * The animation interpolation type
  72203. */
  72204. interpolation?: AnimationKeyInterpolation;
  72205. }
  72206. /**
  72207. * Enum for the animation key frame interpolation type
  72208. */
  72209. export enum AnimationKeyInterpolation {
  72210. /**
  72211. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72212. */
  72213. STEP = 1
  72214. }
  72215. }
  72216. declare module BABYLON {
  72217. /**
  72218. * Represents the range of an animation
  72219. */
  72220. export class AnimationRange {
  72221. /**The name of the animation range**/
  72222. name: string;
  72223. /**The starting frame of the animation */
  72224. from: number;
  72225. /**The ending frame of the animation*/
  72226. to: number;
  72227. /**
  72228. * Initializes the range of an animation
  72229. * @param name The name of the animation range
  72230. * @param from The starting frame of the animation
  72231. * @param to The ending frame of the animation
  72232. */
  72233. constructor(
  72234. /**The name of the animation range**/
  72235. name: string,
  72236. /**The starting frame of the animation */
  72237. from: number,
  72238. /**The ending frame of the animation*/
  72239. to: number);
  72240. /**
  72241. * Makes a copy of the animation range
  72242. * @returns A copy of the animation range
  72243. */
  72244. clone(): AnimationRange;
  72245. }
  72246. }
  72247. declare module BABYLON {
  72248. /**
  72249. * Composed of a frame, and an action function
  72250. */
  72251. export class AnimationEvent {
  72252. /** The frame for which the event is triggered **/
  72253. frame: number;
  72254. /** The event to perform when triggered **/
  72255. action: (currentFrame: number) => void;
  72256. /** Specifies if the event should be triggered only once**/
  72257. onlyOnce?: boolean | undefined;
  72258. /**
  72259. * Specifies if the animation event is done
  72260. */
  72261. isDone: boolean;
  72262. /**
  72263. * Initializes the animation event
  72264. * @param frame The frame for which the event is triggered
  72265. * @param action The event to perform when triggered
  72266. * @param onlyOnce Specifies if the event should be triggered only once
  72267. */
  72268. constructor(
  72269. /** The frame for which the event is triggered **/
  72270. frame: number,
  72271. /** The event to perform when triggered **/
  72272. action: (currentFrame: number) => void,
  72273. /** Specifies if the event should be triggered only once**/
  72274. onlyOnce?: boolean | undefined);
  72275. /** @hidden */
  72276. _clone(): AnimationEvent;
  72277. }
  72278. }
  72279. declare module BABYLON {
  72280. /**
  72281. * Interface used to define a behavior
  72282. */
  72283. export interface Behavior<T> {
  72284. /** gets or sets behavior's name */
  72285. name: string;
  72286. /**
  72287. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72288. */
  72289. init(): void;
  72290. /**
  72291. * Called when the behavior is attached to a target
  72292. * @param target defines the target where the behavior is attached to
  72293. */
  72294. attach(target: T): void;
  72295. /**
  72296. * Called when the behavior is detached from its target
  72297. */
  72298. detach(): void;
  72299. }
  72300. /**
  72301. * Interface implemented by classes supporting behaviors
  72302. */
  72303. export interface IBehaviorAware<T> {
  72304. /**
  72305. * Attach a behavior
  72306. * @param behavior defines the behavior to attach
  72307. * @returns the current host
  72308. */
  72309. addBehavior(behavior: Behavior<T>): T;
  72310. /**
  72311. * Remove a behavior from the current object
  72312. * @param behavior defines the behavior to detach
  72313. * @returns the current host
  72314. */
  72315. removeBehavior(behavior: Behavior<T>): T;
  72316. /**
  72317. * Gets a behavior using its name to search
  72318. * @param name defines the name to search
  72319. * @returns the behavior or null if not found
  72320. */
  72321. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72322. }
  72323. }
  72324. declare module BABYLON {
  72325. /**
  72326. * Defines an array and its length.
  72327. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72328. */
  72329. export interface ISmartArrayLike<T> {
  72330. /**
  72331. * The data of the array.
  72332. */
  72333. data: Array<T>;
  72334. /**
  72335. * The active length of the array.
  72336. */
  72337. length: number;
  72338. }
  72339. /**
  72340. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72341. */
  72342. export class SmartArray<T> implements ISmartArrayLike<T> {
  72343. /**
  72344. * The full set of data from the array.
  72345. */
  72346. data: Array<T>;
  72347. /**
  72348. * The active length of the array.
  72349. */
  72350. length: number;
  72351. protected _id: number;
  72352. /**
  72353. * Instantiates a Smart Array.
  72354. * @param capacity defines the default capacity of the array.
  72355. */
  72356. constructor(capacity: number);
  72357. /**
  72358. * Pushes a value at the end of the active data.
  72359. * @param value defines the object to push in the array.
  72360. */
  72361. push(value: T): void;
  72362. /**
  72363. * Iterates over the active data and apply the lambda to them.
  72364. * @param func defines the action to apply on each value.
  72365. */
  72366. forEach(func: (content: T) => void): void;
  72367. /**
  72368. * Sorts the full sets of data.
  72369. * @param compareFn defines the comparison function to apply.
  72370. */
  72371. sort(compareFn: (a: T, b: T) => number): void;
  72372. /**
  72373. * Resets the active data to an empty array.
  72374. */
  72375. reset(): void;
  72376. /**
  72377. * Releases all the data from the array as well as the array.
  72378. */
  72379. dispose(): void;
  72380. /**
  72381. * Concats the active data with a given array.
  72382. * @param array defines the data to concatenate with.
  72383. */
  72384. concat(array: any): void;
  72385. /**
  72386. * Returns the position of a value in the active data.
  72387. * @param value defines the value to find the index for
  72388. * @returns the index if found in the active data otherwise -1
  72389. */
  72390. indexOf(value: T): number;
  72391. /**
  72392. * Returns whether an element is part of the active data.
  72393. * @param value defines the value to look for
  72394. * @returns true if found in the active data otherwise false
  72395. */
  72396. contains(value: T): boolean;
  72397. private static _GlobalId;
  72398. }
  72399. /**
  72400. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72401. * The data in this array can only be present once
  72402. */
  72403. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72404. private _duplicateId;
  72405. /**
  72406. * Pushes a value at the end of the active data.
  72407. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72408. * @param value defines the object to push in the array.
  72409. */
  72410. push(value: T): void;
  72411. /**
  72412. * Pushes a value at the end of the active data.
  72413. * If the data is already present, it won t be added again
  72414. * @param value defines the object to push in the array.
  72415. * @returns true if added false if it was already present
  72416. */
  72417. pushNoDuplicate(value: T): boolean;
  72418. /**
  72419. * Resets the active data to an empty array.
  72420. */
  72421. reset(): void;
  72422. /**
  72423. * Concats the active data with a given array.
  72424. * This ensures no dupplicate will be present in the result.
  72425. * @param array defines the data to concatenate with.
  72426. */
  72427. concatWithNoDuplicate(array: any): void;
  72428. }
  72429. }
  72430. declare module BABYLON {
  72431. /**
  72432. * @ignore
  72433. * This is a list of all the different input types that are available in the application.
  72434. * Fo instance: ArcRotateCameraGamepadInput...
  72435. */
  72436. export var CameraInputTypes: {};
  72437. /**
  72438. * This is the contract to implement in order to create a new input class.
  72439. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72440. */
  72441. export interface ICameraInput<TCamera extends Camera> {
  72442. /**
  72443. * Defines the camera the input is attached to.
  72444. */
  72445. camera: Nullable<TCamera>;
  72446. /**
  72447. * Gets the class name of the current intput.
  72448. * @returns the class name
  72449. */
  72450. getClassName(): string;
  72451. /**
  72452. * Get the friendly name associated with the input class.
  72453. * @returns the input friendly name
  72454. */
  72455. getSimpleName(): string;
  72456. /**
  72457. * Attach the input controls to a specific dom element to get the input from.
  72458. * @param element Defines the element the controls should be listened from
  72459. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72460. */
  72461. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72462. /**
  72463. * Detach the current controls from the specified dom element.
  72464. * @param element Defines the element to stop listening the inputs from
  72465. */
  72466. detachControl(element: Nullable<HTMLElement>): void;
  72467. /**
  72468. * Update the current camera state depending on the inputs that have been used this frame.
  72469. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72470. */
  72471. checkInputs?: () => void;
  72472. }
  72473. /**
  72474. * Represents a map of input types to input instance or input index to input instance.
  72475. */
  72476. export interface CameraInputsMap<TCamera extends Camera> {
  72477. /**
  72478. * Accessor to the input by input type.
  72479. */
  72480. [name: string]: ICameraInput<TCamera>;
  72481. /**
  72482. * Accessor to the input by input index.
  72483. */
  72484. [idx: number]: ICameraInput<TCamera>;
  72485. }
  72486. /**
  72487. * This represents the input manager used within a camera.
  72488. * It helps dealing with all the different kind of input attached to a camera.
  72489. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72490. */
  72491. export class CameraInputsManager<TCamera extends Camera> {
  72492. /**
  72493. * Defines the list of inputs attahed to the camera.
  72494. */
  72495. attached: CameraInputsMap<TCamera>;
  72496. /**
  72497. * Defines the dom element the camera is collecting inputs from.
  72498. * This is null if the controls have not been attached.
  72499. */
  72500. attachedElement: Nullable<HTMLElement>;
  72501. /**
  72502. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72503. */
  72504. noPreventDefault: boolean;
  72505. /**
  72506. * Defined the camera the input manager belongs to.
  72507. */
  72508. camera: TCamera;
  72509. /**
  72510. * Update the current camera state depending on the inputs that have been used this frame.
  72511. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72512. */
  72513. checkInputs: () => void;
  72514. /**
  72515. * Instantiate a new Camera Input Manager.
  72516. * @param camera Defines the camera the input manager blongs to
  72517. */
  72518. constructor(camera: TCamera);
  72519. /**
  72520. * Add an input method to a camera
  72521. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72522. * @param input camera input method
  72523. */
  72524. add(input: ICameraInput<TCamera>): void;
  72525. /**
  72526. * Remove a specific input method from a camera
  72527. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72528. * @param inputToRemove camera input method
  72529. */
  72530. remove(inputToRemove: ICameraInput<TCamera>): void;
  72531. /**
  72532. * Remove a specific input type from a camera
  72533. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72534. * @param inputType the type of the input to remove
  72535. */
  72536. removeByType(inputType: string): void;
  72537. private _addCheckInputs;
  72538. /**
  72539. * Attach the input controls to the currently attached dom element to listen the events from.
  72540. * @param input Defines the input to attach
  72541. */
  72542. attachInput(input: ICameraInput<TCamera>): void;
  72543. /**
  72544. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72545. * @param element Defines the dom element to collect the events from
  72546. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72547. */
  72548. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72549. /**
  72550. * Detach the current manager inputs controls from a specific dom element.
  72551. * @param element Defines the dom element to collect the events from
  72552. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72553. */
  72554. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72555. /**
  72556. * Rebuild the dynamic inputCheck function from the current list of
  72557. * defined inputs in the manager.
  72558. */
  72559. rebuildInputCheck(): void;
  72560. /**
  72561. * Remove all attached input methods from a camera
  72562. */
  72563. clear(): void;
  72564. /**
  72565. * Serialize the current input manager attached to a camera.
  72566. * This ensures than once parsed,
  72567. * the input associated to the camera will be identical to the current ones
  72568. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72569. */
  72570. serialize(serializedCamera: any): void;
  72571. /**
  72572. * Parses an input manager serialized JSON to restore the previous list of inputs
  72573. * and states associated to a camera.
  72574. * @param parsedCamera Defines the JSON to parse
  72575. */
  72576. parse(parsedCamera: any): void;
  72577. }
  72578. }
  72579. declare module BABYLON {
  72580. /**
  72581. * Class used to store data that will be store in GPU memory
  72582. */
  72583. export class Buffer {
  72584. private _engine;
  72585. private _buffer;
  72586. /** @hidden */
  72587. _data: Nullable<DataArray>;
  72588. private _updatable;
  72589. private _instanced;
  72590. /**
  72591. * Gets the byte stride.
  72592. */
  72593. readonly byteStride: number;
  72594. /**
  72595. * Constructor
  72596. * @param engine the engine
  72597. * @param data the data to use for this buffer
  72598. * @param updatable whether the data is updatable
  72599. * @param stride the stride (optional)
  72600. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  72601. * @param instanced whether the buffer is instanced (optional)
  72602. * @param useBytes set to true if the stride in in bytes (optional)
  72603. */
  72604. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  72605. /**
  72606. * Create a new VertexBuffer based on the current buffer
  72607. * @param kind defines the vertex buffer kind (position, normal, etc.)
  72608. * @param offset defines offset in the buffer (0 by default)
  72609. * @param size defines the size in floats of attributes (position is 3 for instance)
  72610. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  72611. * @param instanced defines if the vertex buffer contains indexed data
  72612. * @param useBytes defines if the offset and stride are in bytes
  72613. * @returns the new vertex buffer
  72614. */
  72615. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  72616. /**
  72617. * Gets a boolean indicating if the Buffer is updatable?
  72618. * @returns true if the buffer is updatable
  72619. */
  72620. isUpdatable(): boolean;
  72621. /**
  72622. * Gets current buffer's data
  72623. * @returns a DataArray or null
  72624. */
  72625. getData(): Nullable<DataArray>;
  72626. /**
  72627. * Gets underlying native buffer
  72628. * @returns underlying native buffer
  72629. */
  72630. getBuffer(): Nullable<DataBuffer>;
  72631. /**
  72632. * Gets the stride in float32 units (i.e. byte stride / 4).
  72633. * May not be an integer if the byte stride is not divisible by 4.
  72634. * DEPRECATED. Use byteStride instead.
  72635. * @returns the stride in float32 units
  72636. */
  72637. getStrideSize(): number;
  72638. /**
  72639. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  72640. * @param data defines the data to store
  72641. */
  72642. create(data?: Nullable<DataArray>): void;
  72643. /** @hidden */
  72644. _rebuild(): void;
  72645. /**
  72646. * Update current buffer data
  72647. * @param data defines the data to store
  72648. */
  72649. update(data: DataArray): void;
  72650. /**
  72651. * Updates the data directly.
  72652. * @param data the new data
  72653. * @param offset the new offset
  72654. * @param vertexCount the vertex count (optional)
  72655. * @param useBytes set to true if the offset is in bytes
  72656. */
  72657. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  72658. /**
  72659. * Release all resources
  72660. */
  72661. dispose(): void;
  72662. }
  72663. /**
  72664. * Specialized buffer used to store vertex data
  72665. */
  72666. export class VertexBuffer {
  72667. /** @hidden */
  72668. _buffer: Buffer;
  72669. private _kind;
  72670. private _size;
  72671. private _ownsBuffer;
  72672. private _instanced;
  72673. private _instanceDivisor;
  72674. /**
  72675. * The byte type.
  72676. */
  72677. static readonly BYTE: number;
  72678. /**
  72679. * The unsigned byte type.
  72680. */
  72681. static readonly UNSIGNED_BYTE: number;
  72682. /**
  72683. * The short type.
  72684. */
  72685. static readonly SHORT: number;
  72686. /**
  72687. * The unsigned short type.
  72688. */
  72689. static readonly UNSIGNED_SHORT: number;
  72690. /**
  72691. * The integer type.
  72692. */
  72693. static readonly INT: number;
  72694. /**
  72695. * The unsigned integer type.
  72696. */
  72697. static readonly UNSIGNED_INT: number;
  72698. /**
  72699. * The float type.
  72700. */
  72701. static readonly FLOAT: number;
  72702. /**
  72703. * Gets or sets the instance divisor when in instanced mode
  72704. */
  72705. instanceDivisor: number;
  72706. /**
  72707. * Gets the byte stride.
  72708. */
  72709. readonly byteStride: number;
  72710. /**
  72711. * Gets the byte offset.
  72712. */
  72713. readonly byteOffset: number;
  72714. /**
  72715. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  72716. */
  72717. readonly normalized: boolean;
  72718. /**
  72719. * Gets the data type of each component in the array.
  72720. */
  72721. readonly type: number;
  72722. /**
  72723. * Constructor
  72724. * @param engine the engine
  72725. * @param data the data to use for this vertex buffer
  72726. * @param kind the vertex buffer kind
  72727. * @param updatable whether the data is updatable
  72728. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  72729. * @param stride the stride (optional)
  72730. * @param instanced whether the buffer is instanced (optional)
  72731. * @param offset the offset of the data (optional)
  72732. * @param size the number of components (optional)
  72733. * @param type the type of the component (optional)
  72734. * @param normalized whether the data contains normalized data (optional)
  72735. * @param useBytes set to true if stride and offset are in bytes (optional)
  72736. */
  72737. 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);
  72738. /** @hidden */
  72739. _rebuild(): void;
  72740. /**
  72741. * Returns the kind of the VertexBuffer (string)
  72742. * @returns a string
  72743. */
  72744. getKind(): string;
  72745. /**
  72746. * Gets a boolean indicating if the VertexBuffer is updatable?
  72747. * @returns true if the buffer is updatable
  72748. */
  72749. isUpdatable(): boolean;
  72750. /**
  72751. * Gets current buffer's data
  72752. * @returns a DataArray or null
  72753. */
  72754. getData(): Nullable<DataArray>;
  72755. /**
  72756. * Gets underlying native buffer
  72757. * @returns underlying native buffer
  72758. */
  72759. getBuffer(): Nullable<DataBuffer>;
  72760. /**
  72761. * Gets the stride in float32 units (i.e. byte stride / 4).
  72762. * May not be an integer if the byte stride is not divisible by 4.
  72763. * DEPRECATED. Use byteStride instead.
  72764. * @returns the stride in float32 units
  72765. */
  72766. getStrideSize(): number;
  72767. /**
  72768. * Returns the offset as a multiple of the type byte length.
  72769. * DEPRECATED. Use byteOffset instead.
  72770. * @returns the offset in bytes
  72771. */
  72772. getOffset(): number;
  72773. /**
  72774. * Returns the number of components per vertex attribute (integer)
  72775. * @returns the size in float
  72776. */
  72777. getSize(): number;
  72778. /**
  72779. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  72780. * @returns true if this buffer is instanced
  72781. */
  72782. getIsInstanced(): boolean;
  72783. /**
  72784. * Returns the instancing divisor, zero for non-instanced (integer).
  72785. * @returns a number
  72786. */
  72787. getInstanceDivisor(): number;
  72788. /**
  72789. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  72790. * @param data defines the data to store
  72791. */
  72792. create(data?: DataArray): void;
  72793. /**
  72794. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  72795. * This function will create a new buffer if the current one is not updatable
  72796. * @param data defines the data to store
  72797. */
  72798. update(data: DataArray): void;
  72799. /**
  72800. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  72801. * Returns the directly updated WebGLBuffer.
  72802. * @param data the new data
  72803. * @param offset the new offset
  72804. * @param useBytes set to true if the offset is in bytes
  72805. */
  72806. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  72807. /**
  72808. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  72809. */
  72810. dispose(): void;
  72811. /**
  72812. * Enumerates each value of this vertex buffer as numbers.
  72813. * @param count the number of values to enumerate
  72814. * @param callback the callback function called for each value
  72815. */
  72816. forEach(count: number, callback: (value: number, index: number) => void): void;
  72817. /**
  72818. * Positions
  72819. */
  72820. static readonly PositionKind: string;
  72821. /**
  72822. * Normals
  72823. */
  72824. static readonly NormalKind: string;
  72825. /**
  72826. * Tangents
  72827. */
  72828. static readonly TangentKind: string;
  72829. /**
  72830. * Texture coordinates
  72831. */
  72832. static readonly UVKind: string;
  72833. /**
  72834. * Texture coordinates 2
  72835. */
  72836. static readonly UV2Kind: string;
  72837. /**
  72838. * Texture coordinates 3
  72839. */
  72840. static readonly UV3Kind: string;
  72841. /**
  72842. * Texture coordinates 4
  72843. */
  72844. static readonly UV4Kind: string;
  72845. /**
  72846. * Texture coordinates 5
  72847. */
  72848. static readonly UV5Kind: string;
  72849. /**
  72850. * Texture coordinates 6
  72851. */
  72852. static readonly UV6Kind: string;
  72853. /**
  72854. * Colors
  72855. */
  72856. static readonly ColorKind: string;
  72857. /**
  72858. * Matrix indices (for bones)
  72859. */
  72860. static readonly MatricesIndicesKind: string;
  72861. /**
  72862. * Matrix weights (for bones)
  72863. */
  72864. static readonly MatricesWeightsKind: string;
  72865. /**
  72866. * Additional matrix indices (for bones)
  72867. */
  72868. static readonly MatricesIndicesExtraKind: string;
  72869. /**
  72870. * Additional matrix weights (for bones)
  72871. */
  72872. static readonly MatricesWeightsExtraKind: string;
  72873. /**
  72874. * Deduces the stride given a kind.
  72875. * @param kind The kind string to deduce
  72876. * @returns The deduced stride
  72877. */
  72878. static DeduceStride(kind: string): number;
  72879. /**
  72880. * Gets the byte length of the given type.
  72881. * @param type the type
  72882. * @returns the number of bytes
  72883. */
  72884. static GetTypeByteLength(type: number): number;
  72885. /**
  72886. * Enumerates each value of the given parameters as numbers.
  72887. * @param data the data to enumerate
  72888. * @param byteOffset the byte offset of the data
  72889. * @param byteStride the byte stride of the data
  72890. * @param componentCount the number of components per element
  72891. * @param componentType the type of the component
  72892. * @param count the number of values to enumerate
  72893. * @param normalized whether the data is normalized
  72894. * @param callback the callback function called for each value
  72895. */
  72896. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  72897. private static _GetFloatValue;
  72898. }
  72899. }
  72900. declare module BABYLON {
  72901. /**
  72902. * @hidden
  72903. */
  72904. export class IntersectionInfo {
  72905. bu: Nullable<number>;
  72906. bv: Nullable<number>;
  72907. distance: number;
  72908. faceId: number;
  72909. subMeshId: number;
  72910. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  72911. }
  72912. }
  72913. declare module BABYLON {
  72914. /**
  72915. * Represens a plane by the equation ax + by + cz + d = 0
  72916. */
  72917. export class Plane {
  72918. private static _TmpMatrix;
  72919. /**
  72920. * Normal of the plane (a,b,c)
  72921. */
  72922. normal: Vector3;
  72923. /**
  72924. * d component of the plane
  72925. */
  72926. d: number;
  72927. /**
  72928. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  72929. * @param a a component of the plane
  72930. * @param b b component of the plane
  72931. * @param c c component of the plane
  72932. * @param d d component of the plane
  72933. */
  72934. constructor(a: number, b: number, c: number, d: number);
  72935. /**
  72936. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  72937. */
  72938. asArray(): number[];
  72939. /**
  72940. * @returns a new plane copied from the current Plane.
  72941. */
  72942. clone(): Plane;
  72943. /**
  72944. * @returns the string "Plane".
  72945. */
  72946. getClassName(): string;
  72947. /**
  72948. * @returns the Plane hash code.
  72949. */
  72950. getHashCode(): number;
  72951. /**
  72952. * Normalize the current Plane in place.
  72953. * @returns the updated Plane.
  72954. */
  72955. normalize(): Plane;
  72956. /**
  72957. * Applies a transformation the plane and returns the result
  72958. * @param transformation the transformation matrix to be applied to the plane
  72959. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  72960. */
  72961. transform(transformation: DeepImmutable<Matrix>): Plane;
  72962. /**
  72963. * Calcualtte the dot product between the point and the plane normal
  72964. * @param point point to calculate the dot product with
  72965. * @returns the dot product (float) of the point coordinates and the plane normal.
  72966. */
  72967. dotCoordinate(point: DeepImmutable<Vector3>): number;
  72968. /**
  72969. * Updates the current Plane from the plane defined by the three given points.
  72970. * @param point1 one of the points used to contruct the plane
  72971. * @param point2 one of the points used to contruct the plane
  72972. * @param point3 one of the points used to contruct the plane
  72973. * @returns the updated Plane.
  72974. */
  72975. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72976. /**
  72977. * Checks if the plane is facing a given direction
  72978. * @param direction the direction to check if the plane is facing
  72979. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  72980. * @returns True is the vector "direction" is the same side than the plane normal.
  72981. */
  72982. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  72983. /**
  72984. * Calculates the distance to a point
  72985. * @param point point to calculate distance to
  72986. * @returns the signed distance (float) from the given point to the Plane.
  72987. */
  72988. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  72989. /**
  72990. * Creates a plane from an array
  72991. * @param array the array to create a plane from
  72992. * @returns a new Plane from the given array.
  72993. */
  72994. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  72995. /**
  72996. * Creates a plane from three points
  72997. * @param point1 point used to create the plane
  72998. * @param point2 point used to create the plane
  72999. * @param point3 point used to create the plane
  73000. * @returns a new Plane defined by the three given points.
  73001. */
  73002. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73003. /**
  73004. * Creates a plane from an origin point and a normal
  73005. * @param origin origin of the plane to be constructed
  73006. * @param normal normal of the plane to be constructed
  73007. * @returns a new Plane the normal vector to this plane at the given origin point.
  73008. * Note : the vector "normal" is updated because normalized.
  73009. */
  73010. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  73011. /**
  73012. * Calculates the distance from a plane and a point
  73013. * @param origin origin of the plane to be constructed
  73014. * @param normal normal of the plane to be constructed
  73015. * @param point point to calculate distance to
  73016. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73017. */
  73018. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  73019. }
  73020. }
  73021. declare module BABYLON {
  73022. /**
  73023. * Class used to store bounding sphere information
  73024. */
  73025. export class BoundingSphere {
  73026. /**
  73027. * Gets the center of the bounding sphere in local space
  73028. */
  73029. readonly center: Vector3;
  73030. /**
  73031. * Radius of the bounding sphere in local space
  73032. */
  73033. radius: number;
  73034. /**
  73035. * Gets the center of the bounding sphere in world space
  73036. */
  73037. readonly centerWorld: Vector3;
  73038. /**
  73039. * Radius of the bounding sphere in world space
  73040. */
  73041. radiusWorld: number;
  73042. /**
  73043. * Gets the minimum vector in local space
  73044. */
  73045. readonly minimum: Vector3;
  73046. /**
  73047. * Gets the maximum vector in local space
  73048. */
  73049. readonly maximum: Vector3;
  73050. private _worldMatrix;
  73051. private static readonly TmpVector3;
  73052. /**
  73053. * Creates a new bounding sphere
  73054. * @param min defines the minimum vector (in local space)
  73055. * @param max defines the maximum vector (in local space)
  73056. * @param worldMatrix defines the new world matrix
  73057. */
  73058. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73059. /**
  73060. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  73061. * @param min defines the new minimum vector (in local space)
  73062. * @param max defines the new maximum vector (in local space)
  73063. * @param worldMatrix defines the new world matrix
  73064. */
  73065. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73066. /**
  73067. * Scale the current bounding sphere by applying a scale factor
  73068. * @param factor defines the scale factor to apply
  73069. * @returns the current bounding box
  73070. */
  73071. scale(factor: number): BoundingSphere;
  73072. /**
  73073. * Gets the world matrix of the bounding box
  73074. * @returns a matrix
  73075. */
  73076. getWorldMatrix(): DeepImmutable<Matrix>;
  73077. /** @hidden */
  73078. _update(worldMatrix: DeepImmutable<Matrix>): void;
  73079. /**
  73080. * Tests if the bounding sphere is intersecting the frustum planes
  73081. * @param frustumPlanes defines the frustum planes to test
  73082. * @returns true if there is an intersection
  73083. */
  73084. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73085. /**
  73086. * Tests if the bounding sphere center is in between the frustum planes.
  73087. * Used for optimistic fast inclusion.
  73088. * @param frustumPlanes defines the frustum planes to test
  73089. * @returns true if the sphere center is in between the frustum planes
  73090. */
  73091. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73092. /**
  73093. * Tests if a point is inside the bounding sphere
  73094. * @param point defines the point to test
  73095. * @returns true if the point is inside the bounding sphere
  73096. */
  73097. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73098. /**
  73099. * Checks if two sphere intersct
  73100. * @param sphere0 sphere 0
  73101. * @param sphere1 sphere 1
  73102. * @returns true if the speres intersect
  73103. */
  73104. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  73105. }
  73106. }
  73107. declare module BABYLON {
  73108. /**
  73109. * Class used to store bounding box information
  73110. */
  73111. export class BoundingBox implements ICullable {
  73112. /**
  73113. * Gets the 8 vectors representing the bounding box in local space
  73114. */
  73115. readonly vectors: Vector3[];
  73116. /**
  73117. * Gets the center of the bounding box in local space
  73118. */
  73119. readonly center: Vector3;
  73120. /**
  73121. * Gets the center of the bounding box in world space
  73122. */
  73123. readonly centerWorld: Vector3;
  73124. /**
  73125. * Gets the extend size in local space
  73126. */
  73127. readonly extendSize: Vector3;
  73128. /**
  73129. * Gets the extend size in world space
  73130. */
  73131. readonly extendSizeWorld: Vector3;
  73132. /**
  73133. * Gets the OBB (object bounding box) directions
  73134. */
  73135. readonly directions: Vector3[];
  73136. /**
  73137. * Gets the 8 vectors representing the bounding box in world space
  73138. */
  73139. readonly vectorsWorld: Vector3[];
  73140. /**
  73141. * Gets the minimum vector in world space
  73142. */
  73143. readonly minimumWorld: Vector3;
  73144. /**
  73145. * Gets the maximum vector in world space
  73146. */
  73147. readonly maximumWorld: Vector3;
  73148. /**
  73149. * Gets the minimum vector in local space
  73150. */
  73151. readonly minimum: Vector3;
  73152. /**
  73153. * Gets the maximum vector in local space
  73154. */
  73155. readonly maximum: Vector3;
  73156. private _worldMatrix;
  73157. private static readonly TmpVector3;
  73158. /**
  73159. * @hidden
  73160. */
  73161. _tag: number;
  73162. /**
  73163. * Creates a new bounding box
  73164. * @param min defines the minimum vector (in local space)
  73165. * @param max defines the maximum vector (in local space)
  73166. * @param worldMatrix defines the new world matrix
  73167. */
  73168. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73169. /**
  73170. * Recreates the entire bounding box from scratch as if we call the constructor in place
  73171. * @param min defines the new minimum vector (in local space)
  73172. * @param max defines the new maximum vector (in local space)
  73173. * @param worldMatrix defines the new world matrix
  73174. */
  73175. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73176. /**
  73177. * Scale the current bounding box by applying a scale factor
  73178. * @param factor defines the scale factor to apply
  73179. * @returns the current bounding box
  73180. */
  73181. scale(factor: number): BoundingBox;
  73182. /**
  73183. * Gets the world matrix of the bounding box
  73184. * @returns a matrix
  73185. */
  73186. getWorldMatrix(): DeepImmutable<Matrix>;
  73187. /** @hidden */
  73188. _update(world: DeepImmutable<Matrix>): void;
  73189. /**
  73190. * Tests if the bounding box is intersecting the frustum planes
  73191. * @param frustumPlanes defines the frustum planes to test
  73192. * @returns true if there is an intersection
  73193. */
  73194. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73195. /**
  73196. * Tests if the bounding box is entirely inside the frustum planes
  73197. * @param frustumPlanes defines the frustum planes to test
  73198. * @returns true if there is an inclusion
  73199. */
  73200. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73201. /**
  73202. * Tests if a point is inside the bounding box
  73203. * @param point defines the point to test
  73204. * @returns true if the point is inside the bounding box
  73205. */
  73206. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73207. /**
  73208. * Tests if the bounding box intersects with a bounding sphere
  73209. * @param sphere defines the sphere to test
  73210. * @returns true if there is an intersection
  73211. */
  73212. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  73213. /**
  73214. * Tests if the bounding box intersects with a box defined by a min and max vectors
  73215. * @param min defines the min vector to use
  73216. * @param max defines the max vector to use
  73217. * @returns true if there is an intersection
  73218. */
  73219. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  73220. /**
  73221. * Tests if two bounding boxes are intersections
  73222. * @param box0 defines the first box to test
  73223. * @param box1 defines the second box to test
  73224. * @returns true if there is an intersection
  73225. */
  73226. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  73227. /**
  73228. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  73229. * @param minPoint defines the minimum vector of the bounding box
  73230. * @param maxPoint defines the maximum vector of the bounding box
  73231. * @param sphereCenter defines the sphere center
  73232. * @param sphereRadius defines the sphere radius
  73233. * @returns true if there is an intersection
  73234. */
  73235. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  73236. /**
  73237. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  73238. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73239. * @param frustumPlanes defines the frustum planes to test
  73240. * @return true if there is an inclusion
  73241. */
  73242. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73243. /**
  73244. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  73245. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73246. * @param frustumPlanes defines the frustum planes to test
  73247. * @return true if there is an intersection
  73248. */
  73249. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73250. }
  73251. }
  73252. declare module BABYLON {
  73253. /** @hidden */
  73254. export class Collider {
  73255. /** Define if a collision was found */
  73256. collisionFound: boolean;
  73257. /**
  73258. * Define last intersection point in local space
  73259. */
  73260. intersectionPoint: Vector3;
  73261. /**
  73262. * Define last collided mesh
  73263. */
  73264. collidedMesh: Nullable<AbstractMesh>;
  73265. private _collisionPoint;
  73266. private _planeIntersectionPoint;
  73267. private _tempVector;
  73268. private _tempVector2;
  73269. private _tempVector3;
  73270. private _tempVector4;
  73271. private _edge;
  73272. private _baseToVertex;
  73273. private _destinationPoint;
  73274. private _slidePlaneNormal;
  73275. private _displacementVector;
  73276. /** @hidden */
  73277. _radius: Vector3;
  73278. /** @hidden */
  73279. _retry: number;
  73280. private _velocity;
  73281. private _basePoint;
  73282. private _epsilon;
  73283. /** @hidden */
  73284. _velocityWorldLength: number;
  73285. /** @hidden */
  73286. _basePointWorld: Vector3;
  73287. private _velocityWorld;
  73288. private _normalizedVelocity;
  73289. /** @hidden */
  73290. _initialVelocity: Vector3;
  73291. /** @hidden */
  73292. _initialPosition: Vector3;
  73293. private _nearestDistance;
  73294. private _collisionMask;
  73295. collisionMask: number;
  73296. /**
  73297. * Gets the plane normal used to compute the sliding response (in local space)
  73298. */
  73299. readonly slidePlaneNormal: Vector3;
  73300. /** @hidden */
  73301. _initialize(source: Vector3, dir: Vector3, e: number): void;
  73302. /** @hidden */
  73303. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  73304. /** @hidden */
  73305. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  73306. /** @hidden */
  73307. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73308. /** @hidden */
  73309. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73310. /** @hidden */
  73311. _getResponse(pos: Vector3, vel: Vector3): void;
  73312. }
  73313. }
  73314. declare module BABYLON {
  73315. /**
  73316. * Interface for cullable objects
  73317. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  73318. */
  73319. export interface ICullable {
  73320. /**
  73321. * Checks if the object or part of the object is in the frustum
  73322. * @param frustumPlanes Camera near/planes
  73323. * @returns true if the object is in frustum otherwise false
  73324. */
  73325. isInFrustum(frustumPlanes: Plane[]): boolean;
  73326. /**
  73327. * Checks if a cullable object (mesh...) is in the camera frustum
  73328. * Unlike isInFrustum this cheks the full bounding box
  73329. * @param frustumPlanes Camera near/planes
  73330. * @returns true if the object is in frustum otherwise false
  73331. */
  73332. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  73333. }
  73334. /**
  73335. * Info for a bounding data of a mesh
  73336. */
  73337. export class BoundingInfo implements ICullable {
  73338. /**
  73339. * Bounding box for the mesh
  73340. */
  73341. readonly boundingBox: BoundingBox;
  73342. /**
  73343. * Bounding sphere for the mesh
  73344. */
  73345. readonly boundingSphere: BoundingSphere;
  73346. private _isLocked;
  73347. private static readonly TmpVector3;
  73348. /**
  73349. * Constructs bounding info
  73350. * @param minimum min vector of the bounding box/sphere
  73351. * @param maximum max vector of the bounding box/sphere
  73352. * @param worldMatrix defines the new world matrix
  73353. */
  73354. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73355. /**
  73356. * Recreates the entire bounding info from scratch as if we call the constructor in place
  73357. * @param min defines the new minimum vector (in local space)
  73358. * @param max defines the new maximum vector (in local space)
  73359. * @param worldMatrix defines the new world matrix
  73360. */
  73361. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73362. /**
  73363. * min vector of the bounding box/sphere
  73364. */
  73365. readonly minimum: Vector3;
  73366. /**
  73367. * max vector of the bounding box/sphere
  73368. */
  73369. readonly maximum: Vector3;
  73370. /**
  73371. * If the info is locked and won't be updated to avoid perf overhead
  73372. */
  73373. isLocked: boolean;
  73374. /**
  73375. * Updates the bounding sphere and box
  73376. * @param world world matrix to be used to update
  73377. */
  73378. update(world: DeepImmutable<Matrix>): void;
  73379. /**
  73380. * Recreate the bounding info to be centered around a specific point given a specific extend.
  73381. * @param center New center of the bounding info
  73382. * @param extend New extend of the bounding info
  73383. * @returns the current bounding info
  73384. */
  73385. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  73386. /**
  73387. * Scale the current bounding info by applying a scale factor
  73388. * @param factor defines the scale factor to apply
  73389. * @returns the current bounding info
  73390. */
  73391. scale(factor: number): BoundingInfo;
  73392. /**
  73393. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  73394. * @param frustumPlanes defines the frustum to test
  73395. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  73396. * @returns true if the bounding info is in the frustum planes
  73397. */
  73398. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73399. /**
  73400. * Gets the world distance between the min and max points of the bounding box
  73401. */
  73402. readonly diagonalLength: number;
  73403. /**
  73404. * Checks if a cullable object (mesh...) is in the camera frustum
  73405. * Unlike isInFrustum this cheks the full bounding box
  73406. * @param frustumPlanes Camera near/planes
  73407. * @returns true if the object is in frustum otherwise false
  73408. */
  73409. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73410. /** @hidden */
  73411. _checkCollision(collider: Collider): boolean;
  73412. /**
  73413. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73414. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73415. * @param point the point to check intersection with
  73416. * @returns if the point intersects
  73417. */
  73418. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73419. /**
  73420. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73421. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73422. * @param boundingInfo the bounding info to check intersection with
  73423. * @param precise if the intersection should be done using OBB
  73424. * @returns if the bounding info intersects
  73425. */
  73426. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73427. }
  73428. }
  73429. declare module BABYLON {
  73430. /**
  73431. * Extracts minimum and maximum values from a list of indexed positions
  73432. * @param positions defines the positions to use
  73433. * @param indices defines the indices to the positions
  73434. * @param indexStart defines the start index
  73435. * @param indexCount defines the end index
  73436. * @param bias defines bias value to add to the result
  73437. * @return minimum and maximum values
  73438. */
  73439. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73440. minimum: Vector3;
  73441. maximum: Vector3;
  73442. };
  73443. /**
  73444. * Extracts minimum and maximum values from a list of positions
  73445. * @param positions defines the positions to use
  73446. * @param start defines the start index in the positions array
  73447. * @param count defines the number of positions to handle
  73448. * @param bias defines bias value to add to the result
  73449. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73450. * @return minimum and maximum values
  73451. */
  73452. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73453. minimum: Vector3;
  73454. maximum: Vector3;
  73455. };
  73456. }
  73457. declare module BABYLON {
  73458. /** @hidden */
  73459. export class WebGLDataBuffer extends DataBuffer {
  73460. private _buffer;
  73461. constructor(resource: WebGLBuffer);
  73462. readonly underlyingResource: any;
  73463. }
  73464. }
  73465. declare module BABYLON {
  73466. /** @hidden */
  73467. export class WebGLPipelineContext implements IPipelineContext {
  73468. engine: ThinEngine;
  73469. program: Nullable<WebGLProgram>;
  73470. context?: WebGLRenderingContext;
  73471. vertexShader?: WebGLShader;
  73472. fragmentShader?: WebGLShader;
  73473. isParallelCompiled: boolean;
  73474. onCompiled?: () => void;
  73475. transformFeedback?: WebGLTransformFeedback | null;
  73476. readonly isAsync: boolean;
  73477. readonly isReady: boolean;
  73478. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  73479. }
  73480. }
  73481. declare module BABYLON {
  73482. interface ThinEngine {
  73483. /**
  73484. * Create an uniform buffer
  73485. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73486. * @param elements defines the content of the uniform buffer
  73487. * @returns the webGL uniform buffer
  73488. */
  73489. createUniformBuffer(elements: FloatArray): DataBuffer;
  73490. /**
  73491. * Create a dynamic uniform buffer
  73492. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73493. * @param elements defines the content of the uniform buffer
  73494. * @returns the webGL uniform buffer
  73495. */
  73496. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  73497. /**
  73498. * Update an existing uniform buffer
  73499. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73500. * @param uniformBuffer defines the target uniform buffer
  73501. * @param elements defines the content to update
  73502. * @param offset defines the offset in the uniform buffer where update should start
  73503. * @param count defines the size of the data to update
  73504. */
  73505. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  73506. /**
  73507. * Bind an uniform buffer to the current webGL context
  73508. * @param buffer defines the buffer to bind
  73509. */
  73510. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  73511. /**
  73512. * Bind a buffer to the current webGL context at a given location
  73513. * @param buffer defines the buffer to bind
  73514. * @param location defines the index where to bind the buffer
  73515. */
  73516. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  73517. /**
  73518. * Bind a specific block at a given index in a specific shader program
  73519. * @param pipelineContext defines the pipeline context to use
  73520. * @param blockName defines the block name
  73521. * @param index defines the index where to bind the block
  73522. */
  73523. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  73524. }
  73525. }
  73526. declare module BABYLON {
  73527. /**
  73528. * Uniform buffer objects.
  73529. *
  73530. * Handles blocks of uniform on the GPU.
  73531. *
  73532. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73533. *
  73534. * For more information, please refer to :
  73535. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73536. */
  73537. export class UniformBuffer {
  73538. private _engine;
  73539. private _buffer;
  73540. private _data;
  73541. private _bufferData;
  73542. private _dynamic?;
  73543. private _uniformLocations;
  73544. private _uniformSizes;
  73545. private _uniformLocationPointer;
  73546. private _needSync;
  73547. private _noUBO;
  73548. private _currentEffect;
  73549. private static _MAX_UNIFORM_SIZE;
  73550. private static _tempBuffer;
  73551. /**
  73552. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  73553. * This is dynamic to allow compat with webgl 1 and 2.
  73554. * You will need to pass the name of the uniform as well as the value.
  73555. */
  73556. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  73557. /**
  73558. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  73559. * This is dynamic to allow compat with webgl 1 and 2.
  73560. * You will need to pass the name of the uniform as well as the value.
  73561. */
  73562. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  73563. /**
  73564. * Lambda to Update a single float in a uniform buffer.
  73565. * This is dynamic to allow compat with webgl 1 and 2.
  73566. * You will need to pass the name of the uniform as well as the value.
  73567. */
  73568. updateFloat: (name: string, x: number) => void;
  73569. /**
  73570. * Lambda to Update a vec2 of float in a uniform buffer.
  73571. * This is dynamic to allow compat with webgl 1 and 2.
  73572. * You will need to pass the name of the uniform as well as the value.
  73573. */
  73574. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  73575. /**
  73576. * Lambda to Update a vec3 of float in a uniform buffer.
  73577. * This is dynamic to allow compat with webgl 1 and 2.
  73578. * You will need to pass the name of the uniform as well as the value.
  73579. */
  73580. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  73581. /**
  73582. * Lambda to Update a vec4 of float in a uniform buffer.
  73583. * This is dynamic to allow compat with webgl 1 and 2.
  73584. * You will need to pass the name of the uniform as well as the value.
  73585. */
  73586. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  73587. /**
  73588. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  73589. * This is dynamic to allow compat with webgl 1 and 2.
  73590. * You will need to pass the name of the uniform as well as the value.
  73591. */
  73592. updateMatrix: (name: string, mat: Matrix) => void;
  73593. /**
  73594. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  73595. * This is dynamic to allow compat with webgl 1 and 2.
  73596. * You will need to pass the name of the uniform as well as the value.
  73597. */
  73598. updateVector3: (name: string, vector: Vector3) => void;
  73599. /**
  73600. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  73601. * This is dynamic to allow compat with webgl 1 and 2.
  73602. * You will need to pass the name of the uniform as well as the value.
  73603. */
  73604. updateVector4: (name: string, vector: Vector4) => void;
  73605. /**
  73606. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  73607. * This is dynamic to allow compat with webgl 1 and 2.
  73608. * You will need to pass the name of the uniform as well as the value.
  73609. */
  73610. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  73611. /**
  73612. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  73613. * This is dynamic to allow compat with webgl 1 and 2.
  73614. * You will need to pass the name of the uniform as well as the value.
  73615. */
  73616. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  73617. /**
  73618. * Instantiates a new Uniform buffer objects.
  73619. *
  73620. * Handles blocks of uniform on the GPU.
  73621. *
  73622. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73623. *
  73624. * For more information, please refer to :
  73625. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73626. * @param engine Define the engine the buffer is associated with
  73627. * @param data Define the data contained in the buffer
  73628. * @param dynamic Define if the buffer is updatable
  73629. */
  73630. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  73631. /**
  73632. * Indicates if the buffer is using the WebGL2 UBO implementation,
  73633. * or just falling back on setUniformXXX calls.
  73634. */
  73635. readonly useUbo: boolean;
  73636. /**
  73637. * Indicates if the WebGL underlying uniform buffer is in sync
  73638. * with the javascript cache data.
  73639. */
  73640. readonly isSync: boolean;
  73641. /**
  73642. * Indicates if the WebGL underlying uniform buffer is dynamic.
  73643. * Also, a dynamic UniformBuffer will disable cache verification and always
  73644. * update the underlying WebGL uniform buffer to the GPU.
  73645. * @returns if Dynamic, otherwise false
  73646. */
  73647. isDynamic(): boolean;
  73648. /**
  73649. * The data cache on JS side.
  73650. * @returns the underlying data as a float array
  73651. */
  73652. getData(): Float32Array;
  73653. /**
  73654. * The underlying WebGL Uniform buffer.
  73655. * @returns the webgl buffer
  73656. */
  73657. getBuffer(): Nullable<DataBuffer>;
  73658. /**
  73659. * std140 layout specifies how to align data within an UBO structure.
  73660. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  73661. * for specs.
  73662. */
  73663. private _fillAlignment;
  73664. /**
  73665. * Adds an uniform in the buffer.
  73666. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  73667. * for the layout to be correct !
  73668. * @param name Name of the uniform, as used in the uniform block in the shader.
  73669. * @param size Data size, or data directly.
  73670. */
  73671. addUniform(name: string, size: number | number[]): void;
  73672. /**
  73673. * Adds a Matrix 4x4 to the uniform buffer.
  73674. * @param name Name of the uniform, as used in the uniform block in the shader.
  73675. * @param mat A 4x4 matrix.
  73676. */
  73677. addMatrix(name: string, mat: Matrix): void;
  73678. /**
  73679. * Adds a vec2 to the uniform buffer.
  73680. * @param name Name of the uniform, as used in the uniform block in the shader.
  73681. * @param x Define the x component value of the vec2
  73682. * @param y Define the y component value of the vec2
  73683. */
  73684. addFloat2(name: string, x: number, y: number): void;
  73685. /**
  73686. * Adds a vec3 to the uniform buffer.
  73687. * @param name Name of the uniform, as used in the uniform block in the shader.
  73688. * @param x Define the x component value of the vec3
  73689. * @param y Define the y component value of the vec3
  73690. * @param z Define the z component value of the vec3
  73691. */
  73692. addFloat3(name: string, x: number, y: number, z: number): void;
  73693. /**
  73694. * Adds a vec3 to the uniform buffer.
  73695. * @param name Name of the uniform, as used in the uniform block in the shader.
  73696. * @param color Define the vec3 from a Color
  73697. */
  73698. addColor3(name: string, color: Color3): void;
  73699. /**
  73700. * Adds a vec4 to the uniform buffer.
  73701. * @param name Name of the uniform, as used in the uniform block in the shader.
  73702. * @param color Define the rgb components from a Color
  73703. * @param alpha Define the a component of the vec4
  73704. */
  73705. addColor4(name: string, color: Color3, alpha: number): void;
  73706. /**
  73707. * Adds a vec3 to the uniform buffer.
  73708. * @param name Name of the uniform, as used in the uniform block in the shader.
  73709. * @param vector Define the vec3 components from a Vector
  73710. */
  73711. addVector3(name: string, vector: Vector3): void;
  73712. /**
  73713. * Adds a Matrix 3x3 to the uniform buffer.
  73714. * @param name Name of the uniform, as used in the uniform block in the shader.
  73715. */
  73716. addMatrix3x3(name: string): void;
  73717. /**
  73718. * Adds a Matrix 2x2 to the uniform buffer.
  73719. * @param name Name of the uniform, as used in the uniform block in the shader.
  73720. */
  73721. addMatrix2x2(name: string): void;
  73722. /**
  73723. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  73724. */
  73725. create(): void;
  73726. /** @hidden */
  73727. _rebuild(): void;
  73728. /**
  73729. * Updates the WebGL Uniform Buffer on the GPU.
  73730. * If the `dynamic` flag is set to true, no cache comparison is done.
  73731. * Otherwise, the buffer will be updated only if the cache differs.
  73732. */
  73733. update(): void;
  73734. /**
  73735. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  73736. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  73737. * @param data Define the flattened data
  73738. * @param size Define the size of the data.
  73739. */
  73740. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  73741. private _valueCache;
  73742. private _cacheMatrix;
  73743. private _updateMatrix3x3ForUniform;
  73744. private _updateMatrix3x3ForEffect;
  73745. private _updateMatrix2x2ForEffect;
  73746. private _updateMatrix2x2ForUniform;
  73747. private _updateFloatForEffect;
  73748. private _updateFloatForUniform;
  73749. private _updateFloat2ForEffect;
  73750. private _updateFloat2ForUniform;
  73751. private _updateFloat3ForEffect;
  73752. private _updateFloat3ForUniform;
  73753. private _updateFloat4ForEffect;
  73754. private _updateFloat4ForUniform;
  73755. private _updateMatrixForEffect;
  73756. private _updateMatrixForUniform;
  73757. private _updateVector3ForEffect;
  73758. private _updateVector3ForUniform;
  73759. private _updateVector4ForEffect;
  73760. private _updateVector4ForUniform;
  73761. private _updateColor3ForEffect;
  73762. private _updateColor3ForUniform;
  73763. private _updateColor4ForEffect;
  73764. private _updateColor4ForUniform;
  73765. /**
  73766. * Sets a sampler uniform on the effect.
  73767. * @param name Define the name of the sampler.
  73768. * @param texture Define the texture to set in the sampler
  73769. */
  73770. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  73771. /**
  73772. * Directly updates the value of the uniform in the cache AND on the GPU.
  73773. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  73774. * @param data Define the flattened data
  73775. */
  73776. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  73777. /**
  73778. * Binds this uniform buffer to an effect.
  73779. * @param effect Define the effect to bind the buffer to
  73780. * @param name Name of the uniform block in the shader.
  73781. */
  73782. bindToEffect(effect: Effect, name: string): void;
  73783. /**
  73784. * Disposes the uniform buffer.
  73785. */
  73786. dispose(): void;
  73787. }
  73788. }
  73789. declare module BABYLON {
  73790. /**
  73791. * Enum that determines the text-wrapping mode to use.
  73792. */
  73793. export enum InspectableType {
  73794. /**
  73795. * Checkbox for booleans
  73796. */
  73797. Checkbox = 0,
  73798. /**
  73799. * Sliders for numbers
  73800. */
  73801. Slider = 1,
  73802. /**
  73803. * Vector3
  73804. */
  73805. Vector3 = 2,
  73806. /**
  73807. * Quaternions
  73808. */
  73809. Quaternion = 3,
  73810. /**
  73811. * Color3
  73812. */
  73813. Color3 = 4,
  73814. /**
  73815. * String
  73816. */
  73817. String = 5
  73818. }
  73819. /**
  73820. * Interface used to define custom inspectable properties.
  73821. * This interface is used by the inspector to display custom property grids
  73822. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73823. */
  73824. export interface IInspectable {
  73825. /**
  73826. * Gets the label to display
  73827. */
  73828. label: string;
  73829. /**
  73830. * Gets the name of the property to edit
  73831. */
  73832. propertyName: string;
  73833. /**
  73834. * Gets the type of the editor to use
  73835. */
  73836. type: InspectableType;
  73837. /**
  73838. * Gets the minimum value of the property when using in "slider" mode
  73839. */
  73840. min?: number;
  73841. /**
  73842. * Gets the maximum value of the property when using in "slider" mode
  73843. */
  73844. max?: number;
  73845. /**
  73846. * Gets the setp to use when using in "slider" mode
  73847. */
  73848. step?: number;
  73849. }
  73850. }
  73851. declare module BABYLON {
  73852. /**
  73853. * Class used to provide helper for timing
  73854. */
  73855. export class TimingTools {
  73856. /**
  73857. * Polyfill for setImmediate
  73858. * @param action defines the action to execute after the current execution block
  73859. */
  73860. static SetImmediate(action: () => void): void;
  73861. }
  73862. }
  73863. declare module BABYLON {
  73864. /**
  73865. * Class used to enable instatition of objects by class name
  73866. */
  73867. export class InstantiationTools {
  73868. /**
  73869. * Use this object to register external classes like custom textures or material
  73870. * to allow the laoders to instantiate them
  73871. */
  73872. static RegisteredExternalClasses: {
  73873. [key: string]: Object;
  73874. };
  73875. /**
  73876. * Tries to instantiate a new object from a given class name
  73877. * @param className defines the class name to instantiate
  73878. * @returns the new object or null if the system was not able to do the instantiation
  73879. */
  73880. static Instantiate(className: string): any;
  73881. }
  73882. }
  73883. declare module BABYLON {
  73884. /**
  73885. * Define options used to create a depth texture
  73886. */
  73887. export class DepthTextureCreationOptions {
  73888. /** Specifies whether or not a stencil should be allocated in the texture */
  73889. generateStencil?: boolean;
  73890. /** Specifies whether or not bilinear filtering is enable on the texture */
  73891. bilinearFiltering?: boolean;
  73892. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  73893. comparisonFunction?: number;
  73894. /** Specifies if the created texture is a cube texture */
  73895. isCube?: boolean;
  73896. }
  73897. }
  73898. declare module BABYLON {
  73899. interface ThinEngine {
  73900. /**
  73901. * Creates a depth stencil cube texture.
  73902. * This is only available in WebGL 2.
  73903. * @param size The size of face edge in the cube texture.
  73904. * @param options The options defining the cube texture.
  73905. * @returns The cube texture
  73906. */
  73907. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  73908. /**
  73909. * Creates a cube texture
  73910. * @param rootUrl defines the url where the files to load is located
  73911. * @param scene defines the current scene
  73912. * @param files defines the list of files to load (1 per face)
  73913. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73914. * @param onLoad defines an optional callback raised when the texture is loaded
  73915. * @param onError defines an optional callback raised if there is an issue to load the texture
  73916. * @param format defines the format of the data
  73917. * @param forcedExtension defines the extension to use to pick the right loader
  73918. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73919. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73920. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73921. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  73922. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  73923. * @returns the cube texture as an InternalTexture
  73924. */
  73925. 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;
  73926. /**
  73927. * Creates a cube texture
  73928. * @param rootUrl defines the url where the files to load is located
  73929. * @param scene defines the current scene
  73930. * @param files defines the list of files to load (1 per face)
  73931. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73932. * @param onLoad defines an optional callback raised when the texture is loaded
  73933. * @param onError defines an optional callback raised if there is an issue to load the texture
  73934. * @param format defines the format of the data
  73935. * @param forcedExtension defines the extension to use to pick the right loader
  73936. * @returns the cube texture as an InternalTexture
  73937. */
  73938. 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;
  73939. /**
  73940. * Creates a cube texture
  73941. * @param rootUrl defines the url where the files to load is located
  73942. * @param scene defines the current scene
  73943. * @param files defines the list of files to load (1 per face)
  73944. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73945. * @param onLoad defines an optional callback raised when the texture is loaded
  73946. * @param onError defines an optional callback raised if there is an issue to load the texture
  73947. * @param format defines the format of the data
  73948. * @param forcedExtension defines the extension to use to pick the right loader
  73949. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73950. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73951. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73952. * @returns the cube texture as an InternalTexture
  73953. */
  73954. 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;
  73955. /** @hidden */
  73956. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73957. /** @hidden */
  73958. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73959. /** @hidden */
  73960. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73961. /** @hidden */
  73962. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73963. }
  73964. }
  73965. declare module BABYLON {
  73966. /**
  73967. * Class for creating a cube texture
  73968. */
  73969. export class CubeTexture extends BaseTexture {
  73970. private _delayedOnLoad;
  73971. /**
  73972. * The url of the texture
  73973. */
  73974. url: string;
  73975. /**
  73976. * Gets or sets the center of the bounding box associated with the cube texture.
  73977. * It must define where the camera used to render the texture was set
  73978. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73979. */
  73980. boundingBoxPosition: Vector3;
  73981. private _boundingBoxSize;
  73982. /**
  73983. * Gets or sets the size of the bounding box associated with the cube texture
  73984. * When defined, the cubemap will switch to local mode
  73985. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  73986. * @example https://www.babylonjs-playground.com/#RNASML
  73987. */
  73988. /**
  73989. * Returns the bounding box size
  73990. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73991. */
  73992. boundingBoxSize: Vector3;
  73993. protected _rotationY: number;
  73994. /**
  73995. * Sets texture matrix rotation angle around Y axis in radians.
  73996. */
  73997. /**
  73998. * Gets texture matrix rotation angle around Y axis radians.
  73999. */
  74000. rotationY: number;
  74001. /**
  74002. * Are mip maps generated for this texture or not.
  74003. */
  74004. readonly noMipmap: boolean;
  74005. private _noMipmap;
  74006. private _files;
  74007. private _extensions;
  74008. private _textureMatrix;
  74009. private _format;
  74010. private _createPolynomials;
  74011. /** @hidden */
  74012. _prefiltered: boolean;
  74013. /**
  74014. * Creates a cube texture from an array of image urls
  74015. * @param files defines an array of image urls
  74016. * @param scene defines the hosting scene
  74017. * @param noMipmap specifies if mip maps are not used
  74018. * @returns a cube texture
  74019. */
  74020. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  74021. /**
  74022. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  74023. * @param url defines the url of the prefiltered texture
  74024. * @param scene defines the scene the texture is attached to
  74025. * @param forcedExtension defines the extension of the file if different from the url
  74026. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74027. * @return the prefiltered texture
  74028. */
  74029. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  74030. /**
  74031. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  74032. * as prefiltered data.
  74033. * @param rootUrl defines the url of the texture or the root name of the six images
  74034. * @param scene defines the scene the texture is attached to
  74035. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  74036. * @param noMipmap defines if mipmaps should be created or not
  74037. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  74038. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  74039. * @param onError defines a callback triggered in case of error during load
  74040. * @param format defines the internal format to use for the texture once loaded
  74041. * @param prefiltered defines whether or not the texture is created from prefiltered data
  74042. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  74043. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74044. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74045. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74046. * @return the cube texture
  74047. */
  74048. 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);
  74049. /**
  74050. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  74051. */
  74052. readonly isPrefiltered: boolean;
  74053. /**
  74054. * Get the current class name of the texture useful for serialization or dynamic coding.
  74055. * @returns "CubeTexture"
  74056. */
  74057. getClassName(): string;
  74058. /**
  74059. * Update the url (and optional buffer) of this texture if url was null during construction.
  74060. * @param url the url of the texture
  74061. * @param forcedExtension defines the extension to use
  74062. * @param onLoad callback called when the texture is loaded (defaults to null)
  74063. */
  74064. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  74065. /**
  74066. * Delays loading of the cube texture
  74067. * @param forcedExtension defines the extension to use
  74068. */
  74069. delayLoad(forcedExtension?: string): void;
  74070. /**
  74071. * Returns the reflection texture matrix
  74072. * @returns the reflection texture matrix
  74073. */
  74074. getReflectionTextureMatrix(): Matrix;
  74075. /**
  74076. * Sets the reflection texture matrix
  74077. * @param value Reflection texture matrix
  74078. */
  74079. setReflectionTextureMatrix(value: Matrix): void;
  74080. /**
  74081. * Parses text to create a cube texture
  74082. * @param parsedTexture define the serialized text to read from
  74083. * @param scene defines the hosting scene
  74084. * @param rootUrl defines the root url of the cube texture
  74085. * @returns a cube texture
  74086. */
  74087. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  74088. /**
  74089. * Makes a clone, or deep copy, of the cube texture
  74090. * @returns a new cube texture
  74091. */
  74092. clone(): CubeTexture;
  74093. }
  74094. }
  74095. declare module BABYLON {
  74096. /**
  74097. * Manages the defines for the Material
  74098. */
  74099. export class MaterialDefines {
  74100. /** @hidden */
  74101. protected _keys: string[];
  74102. private _isDirty;
  74103. /** @hidden */
  74104. _renderId: number;
  74105. /** @hidden */
  74106. _areLightsDirty: boolean;
  74107. /** @hidden */
  74108. _areLightsDisposed: boolean;
  74109. /** @hidden */
  74110. _areAttributesDirty: boolean;
  74111. /** @hidden */
  74112. _areTexturesDirty: boolean;
  74113. /** @hidden */
  74114. _areFresnelDirty: boolean;
  74115. /** @hidden */
  74116. _areMiscDirty: boolean;
  74117. /** @hidden */
  74118. _areImageProcessingDirty: boolean;
  74119. /** @hidden */
  74120. _normals: boolean;
  74121. /** @hidden */
  74122. _uvs: boolean;
  74123. /** @hidden */
  74124. _needNormals: boolean;
  74125. /** @hidden */
  74126. _needUVs: boolean;
  74127. [id: string]: any;
  74128. /**
  74129. * Specifies if the material needs to be re-calculated
  74130. */
  74131. readonly isDirty: boolean;
  74132. /**
  74133. * Marks the material to indicate that it has been re-calculated
  74134. */
  74135. markAsProcessed(): void;
  74136. /**
  74137. * Marks the material to indicate that it needs to be re-calculated
  74138. */
  74139. markAsUnprocessed(): void;
  74140. /**
  74141. * Marks the material to indicate all of its defines need to be re-calculated
  74142. */
  74143. markAllAsDirty(): void;
  74144. /**
  74145. * Marks the material to indicate that image processing needs to be re-calculated
  74146. */
  74147. markAsImageProcessingDirty(): void;
  74148. /**
  74149. * Marks the material to indicate the lights need to be re-calculated
  74150. * @param disposed Defines whether the light is dirty due to dispose or not
  74151. */
  74152. markAsLightDirty(disposed?: boolean): void;
  74153. /**
  74154. * Marks the attribute state as changed
  74155. */
  74156. markAsAttributesDirty(): void;
  74157. /**
  74158. * Marks the texture state as changed
  74159. */
  74160. markAsTexturesDirty(): void;
  74161. /**
  74162. * Marks the fresnel state as changed
  74163. */
  74164. markAsFresnelDirty(): void;
  74165. /**
  74166. * Marks the misc state as changed
  74167. */
  74168. markAsMiscDirty(): void;
  74169. /**
  74170. * Rebuilds the material defines
  74171. */
  74172. rebuild(): void;
  74173. /**
  74174. * Specifies if two material defines are equal
  74175. * @param other - A material define instance to compare to
  74176. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  74177. */
  74178. isEqual(other: MaterialDefines): boolean;
  74179. /**
  74180. * Clones this instance's defines to another instance
  74181. * @param other - material defines to clone values to
  74182. */
  74183. cloneTo(other: MaterialDefines): void;
  74184. /**
  74185. * Resets the material define values
  74186. */
  74187. reset(): void;
  74188. /**
  74189. * Converts the material define values to a string
  74190. * @returns - String of material define information
  74191. */
  74192. toString(): string;
  74193. }
  74194. }
  74195. declare module BABYLON {
  74196. /**
  74197. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  74198. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  74199. * 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;
  74200. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  74201. */
  74202. export class ColorCurves {
  74203. private _dirty;
  74204. private _tempColor;
  74205. private _globalCurve;
  74206. private _highlightsCurve;
  74207. private _midtonesCurve;
  74208. private _shadowsCurve;
  74209. private _positiveCurve;
  74210. private _negativeCurve;
  74211. private _globalHue;
  74212. private _globalDensity;
  74213. private _globalSaturation;
  74214. private _globalExposure;
  74215. /**
  74216. * Gets the global Hue value.
  74217. * 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).
  74218. */
  74219. /**
  74220. * Sets the global Hue value.
  74221. * 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).
  74222. */
  74223. globalHue: number;
  74224. /**
  74225. * Gets the global Density value.
  74226. * 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.
  74227. * Values less than zero provide a filter of opposite hue.
  74228. */
  74229. /**
  74230. * Sets the global Density value.
  74231. * 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.
  74232. * Values less than zero provide a filter of opposite hue.
  74233. */
  74234. globalDensity: number;
  74235. /**
  74236. * Gets the global Saturation value.
  74237. * 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.
  74238. */
  74239. /**
  74240. * Sets the global Saturation value.
  74241. * 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.
  74242. */
  74243. globalSaturation: number;
  74244. /**
  74245. * Gets the global Exposure value.
  74246. * 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.
  74247. */
  74248. /**
  74249. * Sets the global Exposure value.
  74250. * 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.
  74251. */
  74252. globalExposure: number;
  74253. private _highlightsHue;
  74254. private _highlightsDensity;
  74255. private _highlightsSaturation;
  74256. private _highlightsExposure;
  74257. /**
  74258. * Gets the highlights Hue value.
  74259. * 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).
  74260. */
  74261. /**
  74262. * Sets the highlights Hue value.
  74263. * 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).
  74264. */
  74265. highlightsHue: number;
  74266. /**
  74267. * Gets the highlights Density value.
  74268. * 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.
  74269. * Values less than zero provide a filter of opposite hue.
  74270. */
  74271. /**
  74272. * Sets the highlights Density value.
  74273. * 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.
  74274. * Values less than zero provide a filter of opposite hue.
  74275. */
  74276. highlightsDensity: number;
  74277. /**
  74278. * Gets the highlights Saturation value.
  74279. * 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.
  74280. */
  74281. /**
  74282. * Sets the highlights Saturation value.
  74283. * 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.
  74284. */
  74285. highlightsSaturation: number;
  74286. /**
  74287. * Gets the highlights Exposure value.
  74288. * 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.
  74289. */
  74290. /**
  74291. * Sets the highlights Exposure value.
  74292. * 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.
  74293. */
  74294. highlightsExposure: number;
  74295. private _midtonesHue;
  74296. private _midtonesDensity;
  74297. private _midtonesSaturation;
  74298. private _midtonesExposure;
  74299. /**
  74300. * Gets the midtones Hue value.
  74301. * 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).
  74302. */
  74303. /**
  74304. * Sets the midtones Hue value.
  74305. * 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).
  74306. */
  74307. midtonesHue: number;
  74308. /**
  74309. * Gets the midtones Density value.
  74310. * 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.
  74311. * Values less than zero provide a filter of opposite hue.
  74312. */
  74313. /**
  74314. * Sets the midtones Density value.
  74315. * 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.
  74316. * Values less than zero provide a filter of opposite hue.
  74317. */
  74318. midtonesDensity: number;
  74319. /**
  74320. * Gets the midtones Saturation value.
  74321. * 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.
  74322. */
  74323. /**
  74324. * Sets the midtones Saturation value.
  74325. * 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.
  74326. */
  74327. midtonesSaturation: number;
  74328. /**
  74329. * Gets the midtones Exposure value.
  74330. * 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.
  74331. */
  74332. /**
  74333. * Sets the midtones Exposure value.
  74334. * 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.
  74335. */
  74336. midtonesExposure: number;
  74337. private _shadowsHue;
  74338. private _shadowsDensity;
  74339. private _shadowsSaturation;
  74340. private _shadowsExposure;
  74341. /**
  74342. * Gets the shadows Hue value.
  74343. * 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).
  74344. */
  74345. /**
  74346. * Sets the shadows Hue value.
  74347. * 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).
  74348. */
  74349. shadowsHue: number;
  74350. /**
  74351. * Gets the shadows Density value.
  74352. * 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.
  74353. * Values less than zero provide a filter of opposite hue.
  74354. */
  74355. /**
  74356. * Sets the shadows Density value.
  74357. * 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.
  74358. * Values less than zero provide a filter of opposite hue.
  74359. */
  74360. shadowsDensity: number;
  74361. /**
  74362. * Gets the shadows Saturation value.
  74363. * 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.
  74364. */
  74365. /**
  74366. * Sets the shadows Saturation value.
  74367. * 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.
  74368. */
  74369. shadowsSaturation: number;
  74370. /**
  74371. * Gets the shadows Exposure value.
  74372. * 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.
  74373. */
  74374. /**
  74375. * Sets the shadows Exposure value.
  74376. * 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.
  74377. */
  74378. shadowsExposure: number;
  74379. /**
  74380. * Returns the class name
  74381. * @returns The class name
  74382. */
  74383. getClassName(): string;
  74384. /**
  74385. * Binds the color curves to the shader.
  74386. * @param colorCurves The color curve to bind
  74387. * @param effect The effect to bind to
  74388. * @param positiveUniform The positive uniform shader parameter
  74389. * @param neutralUniform The neutral uniform shader parameter
  74390. * @param negativeUniform The negative uniform shader parameter
  74391. */
  74392. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  74393. /**
  74394. * Prepare the list of uniforms associated with the ColorCurves effects.
  74395. * @param uniformsList The list of uniforms used in the effect
  74396. */
  74397. static PrepareUniforms(uniformsList: string[]): void;
  74398. /**
  74399. * Returns color grading data based on a hue, density, saturation and exposure value.
  74400. * @param filterHue The hue of the color filter.
  74401. * @param filterDensity The density of the color filter.
  74402. * @param saturation The saturation.
  74403. * @param exposure The exposure.
  74404. * @param result The result data container.
  74405. */
  74406. private getColorGradingDataToRef;
  74407. /**
  74408. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  74409. * @param value The input slider value in range [-100,100].
  74410. * @returns Adjusted value.
  74411. */
  74412. private static applyColorGradingSliderNonlinear;
  74413. /**
  74414. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  74415. * @param hue The hue (H) input.
  74416. * @param saturation The saturation (S) input.
  74417. * @param brightness The brightness (B) input.
  74418. * @result An RGBA color represented as Vector4.
  74419. */
  74420. private static fromHSBToRef;
  74421. /**
  74422. * Returns a value clamped between min and max
  74423. * @param value The value to clamp
  74424. * @param min The minimum of value
  74425. * @param max The maximum of value
  74426. * @returns The clamped value.
  74427. */
  74428. private static clamp;
  74429. /**
  74430. * Clones the current color curve instance.
  74431. * @return The cloned curves
  74432. */
  74433. clone(): ColorCurves;
  74434. /**
  74435. * Serializes the current color curve instance to a json representation.
  74436. * @return a JSON representation
  74437. */
  74438. serialize(): any;
  74439. /**
  74440. * Parses the color curve from a json representation.
  74441. * @param source the JSON source to parse
  74442. * @return The parsed curves
  74443. */
  74444. static Parse(source: any): ColorCurves;
  74445. }
  74446. }
  74447. declare module BABYLON {
  74448. /**
  74449. * Interface to follow in your material defines to integrate easily the
  74450. * Image proccessing functions.
  74451. * @hidden
  74452. */
  74453. export interface IImageProcessingConfigurationDefines {
  74454. IMAGEPROCESSING: boolean;
  74455. VIGNETTE: boolean;
  74456. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74457. VIGNETTEBLENDMODEOPAQUE: boolean;
  74458. TONEMAPPING: boolean;
  74459. TONEMAPPING_ACES: boolean;
  74460. CONTRAST: boolean;
  74461. EXPOSURE: boolean;
  74462. COLORCURVES: boolean;
  74463. COLORGRADING: boolean;
  74464. COLORGRADING3D: boolean;
  74465. SAMPLER3DGREENDEPTH: boolean;
  74466. SAMPLER3DBGRMAP: boolean;
  74467. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74468. }
  74469. /**
  74470. * @hidden
  74471. */
  74472. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  74473. IMAGEPROCESSING: boolean;
  74474. VIGNETTE: boolean;
  74475. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74476. VIGNETTEBLENDMODEOPAQUE: boolean;
  74477. TONEMAPPING: boolean;
  74478. TONEMAPPING_ACES: boolean;
  74479. CONTRAST: boolean;
  74480. COLORCURVES: boolean;
  74481. COLORGRADING: boolean;
  74482. COLORGRADING3D: boolean;
  74483. SAMPLER3DGREENDEPTH: boolean;
  74484. SAMPLER3DBGRMAP: boolean;
  74485. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74486. EXPOSURE: boolean;
  74487. constructor();
  74488. }
  74489. /**
  74490. * This groups together the common properties used for image processing either in direct forward pass
  74491. * or through post processing effect depending on the use of the image processing pipeline in your scene
  74492. * or not.
  74493. */
  74494. export class ImageProcessingConfiguration {
  74495. /**
  74496. * Default tone mapping applied in BabylonJS.
  74497. */
  74498. static readonly TONEMAPPING_STANDARD: number;
  74499. /**
  74500. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  74501. * to other engines rendering to increase portability.
  74502. */
  74503. static readonly TONEMAPPING_ACES: number;
  74504. /**
  74505. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  74506. */
  74507. colorCurves: Nullable<ColorCurves>;
  74508. private _colorCurvesEnabled;
  74509. /**
  74510. * Gets wether the color curves effect is enabled.
  74511. */
  74512. /**
  74513. * Sets wether the color curves effect is enabled.
  74514. */
  74515. colorCurvesEnabled: boolean;
  74516. private _colorGradingTexture;
  74517. /**
  74518. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74519. */
  74520. /**
  74521. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74522. */
  74523. colorGradingTexture: Nullable<BaseTexture>;
  74524. private _colorGradingEnabled;
  74525. /**
  74526. * Gets wether the color grading effect is enabled.
  74527. */
  74528. /**
  74529. * Sets wether the color grading effect is enabled.
  74530. */
  74531. colorGradingEnabled: boolean;
  74532. private _colorGradingWithGreenDepth;
  74533. /**
  74534. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  74535. */
  74536. /**
  74537. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  74538. */
  74539. colorGradingWithGreenDepth: boolean;
  74540. private _colorGradingBGR;
  74541. /**
  74542. * Gets wether the color grading texture contains BGR values.
  74543. */
  74544. /**
  74545. * Sets wether the color grading texture contains BGR values.
  74546. */
  74547. colorGradingBGR: boolean;
  74548. /** @hidden */
  74549. _exposure: number;
  74550. /**
  74551. * Gets the Exposure used in the effect.
  74552. */
  74553. /**
  74554. * Sets the Exposure used in the effect.
  74555. */
  74556. exposure: number;
  74557. private _toneMappingEnabled;
  74558. /**
  74559. * Gets wether the tone mapping effect is enabled.
  74560. */
  74561. /**
  74562. * Sets wether the tone mapping effect is enabled.
  74563. */
  74564. toneMappingEnabled: boolean;
  74565. private _toneMappingType;
  74566. /**
  74567. * Gets the type of tone mapping effect.
  74568. */
  74569. /**
  74570. * Sets the type of tone mapping effect used in BabylonJS.
  74571. */
  74572. toneMappingType: number;
  74573. protected _contrast: number;
  74574. /**
  74575. * Gets the contrast used in the effect.
  74576. */
  74577. /**
  74578. * Sets the contrast used in the effect.
  74579. */
  74580. contrast: number;
  74581. /**
  74582. * Vignette stretch size.
  74583. */
  74584. vignetteStretch: number;
  74585. /**
  74586. * Vignette centre X Offset.
  74587. */
  74588. vignetteCentreX: number;
  74589. /**
  74590. * Vignette centre Y Offset.
  74591. */
  74592. vignetteCentreY: number;
  74593. /**
  74594. * Vignette weight or intensity of the vignette effect.
  74595. */
  74596. vignetteWeight: number;
  74597. /**
  74598. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  74599. * if vignetteEnabled is set to true.
  74600. */
  74601. vignetteColor: Color4;
  74602. /**
  74603. * Camera field of view used by the Vignette effect.
  74604. */
  74605. vignetteCameraFov: number;
  74606. private _vignetteBlendMode;
  74607. /**
  74608. * Gets the vignette blend mode allowing different kind of effect.
  74609. */
  74610. /**
  74611. * Sets the vignette blend mode allowing different kind of effect.
  74612. */
  74613. vignetteBlendMode: number;
  74614. private _vignetteEnabled;
  74615. /**
  74616. * Gets wether the vignette effect is enabled.
  74617. */
  74618. /**
  74619. * Sets wether the vignette effect is enabled.
  74620. */
  74621. vignetteEnabled: boolean;
  74622. private _applyByPostProcess;
  74623. /**
  74624. * Gets wether the image processing is applied through a post process or not.
  74625. */
  74626. /**
  74627. * Sets wether the image processing is applied through a post process or not.
  74628. */
  74629. applyByPostProcess: boolean;
  74630. private _isEnabled;
  74631. /**
  74632. * Gets wether the image processing is enabled or not.
  74633. */
  74634. /**
  74635. * Sets wether the image processing is enabled or not.
  74636. */
  74637. isEnabled: boolean;
  74638. /**
  74639. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  74640. */
  74641. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  74642. /**
  74643. * Method called each time the image processing information changes requires to recompile the effect.
  74644. */
  74645. protected _updateParameters(): void;
  74646. /**
  74647. * Gets the current class name.
  74648. * @return "ImageProcessingConfiguration"
  74649. */
  74650. getClassName(): string;
  74651. /**
  74652. * Prepare the list of uniforms associated with the Image Processing effects.
  74653. * @param uniforms The list of uniforms used in the effect
  74654. * @param defines the list of defines currently in use
  74655. */
  74656. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  74657. /**
  74658. * Prepare the list of samplers associated with the Image Processing effects.
  74659. * @param samplersList The list of uniforms used in the effect
  74660. * @param defines the list of defines currently in use
  74661. */
  74662. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  74663. /**
  74664. * Prepare the list of defines associated to the shader.
  74665. * @param defines the list of defines to complete
  74666. * @param forPostProcess Define if we are currently in post process mode or not
  74667. */
  74668. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  74669. /**
  74670. * Returns true if all the image processing information are ready.
  74671. * @returns True if ready, otherwise, false
  74672. */
  74673. isReady(): boolean;
  74674. /**
  74675. * Binds the image processing to the shader.
  74676. * @param effect The effect to bind to
  74677. * @param aspectRatio Define the current aspect ratio of the effect
  74678. */
  74679. bind(effect: Effect, aspectRatio?: number): void;
  74680. /**
  74681. * Clones the current image processing instance.
  74682. * @return The cloned image processing
  74683. */
  74684. clone(): ImageProcessingConfiguration;
  74685. /**
  74686. * Serializes the current image processing instance to a json representation.
  74687. * @return a JSON representation
  74688. */
  74689. serialize(): any;
  74690. /**
  74691. * Parses the image processing from a json representation.
  74692. * @param source the JSON source to parse
  74693. * @return The parsed image processing
  74694. */
  74695. static Parse(source: any): ImageProcessingConfiguration;
  74696. private static _VIGNETTEMODE_MULTIPLY;
  74697. private static _VIGNETTEMODE_OPAQUE;
  74698. /**
  74699. * Used to apply the vignette as a mix with the pixel color.
  74700. */
  74701. static readonly VIGNETTEMODE_MULTIPLY: number;
  74702. /**
  74703. * Used to apply the vignette as a replacement of the pixel color.
  74704. */
  74705. static readonly VIGNETTEMODE_OPAQUE: number;
  74706. }
  74707. }
  74708. declare module BABYLON {
  74709. /** @hidden */
  74710. export var postprocessVertexShader: {
  74711. name: string;
  74712. shader: string;
  74713. };
  74714. }
  74715. declare module BABYLON {
  74716. /** Defines supported spaces */
  74717. export enum Space {
  74718. /** Local (object) space */
  74719. LOCAL = 0,
  74720. /** World space */
  74721. WORLD = 1,
  74722. /** Bone space */
  74723. BONE = 2
  74724. }
  74725. /** Defines the 3 main axes */
  74726. export class Axis {
  74727. /** X axis */
  74728. static X: Vector3;
  74729. /** Y axis */
  74730. static Y: Vector3;
  74731. /** Z axis */
  74732. static Z: Vector3;
  74733. }
  74734. }
  74735. declare module BABYLON {
  74736. /**
  74737. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  74738. * This is the base of the follow, arc rotate cameras and Free camera
  74739. * @see http://doc.babylonjs.com/features/cameras
  74740. */
  74741. export class TargetCamera extends Camera {
  74742. private static _RigCamTransformMatrix;
  74743. private static _TargetTransformMatrix;
  74744. private static _TargetFocalPoint;
  74745. /**
  74746. * Define the current direction the camera is moving to
  74747. */
  74748. cameraDirection: Vector3;
  74749. /**
  74750. * Define the current rotation the camera is rotating to
  74751. */
  74752. cameraRotation: Vector2;
  74753. /**
  74754. * When set, the up vector of the camera will be updated by the rotation of the camera
  74755. */
  74756. updateUpVectorFromRotation: boolean;
  74757. private _tmpQuaternion;
  74758. /**
  74759. * Define the current rotation of the camera
  74760. */
  74761. rotation: Vector3;
  74762. /**
  74763. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  74764. */
  74765. rotationQuaternion: Quaternion;
  74766. /**
  74767. * Define the current speed of the camera
  74768. */
  74769. speed: number;
  74770. /**
  74771. * Add cconstraint to the camera to prevent it to move freely in all directions and
  74772. * around all axis.
  74773. */
  74774. noRotationConstraint: boolean;
  74775. /**
  74776. * Define the current target of the camera as an object or a position.
  74777. */
  74778. lockedTarget: any;
  74779. /** @hidden */
  74780. _currentTarget: Vector3;
  74781. /** @hidden */
  74782. _initialFocalDistance: number;
  74783. /** @hidden */
  74784. _viewMatrix: Matrix;
  74785. /** @hidden */
  74786. _camMatrix: Matrix;
  74787. /** @hidden */
  74788. _cameraTransformMatrix: Matrix;
  74789. /** @hidden */
  74790. _cameraRotationMatrix: Matrix;
  74791. /** @hidden */
  74792. _referencePoint: Vector3;
  74793. /** @hidden */
  74794. _transformedReferencePoint: Vector3;
  74795. protected _globalCurrentTarget: Vector3;
  74796. protected _globalCurrentUpVector: Vector3;
  74797. /** @hidden */
  74798. _reset: () => void;
  74799. private _defaultUp;
  74800. /**
  74801. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  74802. * This is the base of the follow, arc rotate cameras and Free camera
  74803. * @see http://doc.babylonjs.com/features/cameras
  74804. * @param name Defines the name of the camera in the scene
  74805. * @param position Defines the start position of the camera in the scene
  74806. * @param scene Defines the scene the camera belongs to
  74807. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  74808. */
  74809. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  74810. /**
  74811. * Gets the position in front of the camera at a given distance.
  74812. * @param distance The distance from the camera we want the position to be
  74813. * @returns the position
  74814. */
  74815. getFrontPosition(distance: number): Vector3;
  74816. /** @hidden */
  74817. _getLockedTargetPosition(): Nullable<Vector3>;
  74818. private _storedPosition;
  74819. private _storedRotation;
  74820. private _storedRotationQuaternion;
  74821. /**
  74822. * Store current camera state of the camera (fov, position, rotation, etc..)
  74823. * @returns the camera
  74824. */
  74825. storeState(): Camera;
  74826. /**
  74827. * Restored camera state. You must call storeState() first
  74828. * @returns whether it was successful or not
  74829. * @hidden
  74830. */
  74831. _restoreStateValues(): boolean;
  74832. /** @hidden */
  74833. _initCache(): void;
  74834. /** @hidden */
  74835. _updateCache(ignoreParentClass?: boolean): void;
  74836. /** @hidden */
  74837. _isSynchronizedViewMatrix(): boolean;
  74838. /** @hidden */
  74839. _computeLocalCameraSpeed(): number;
  74840. /**
  74841. * Defines the target the camera should look at.
  74842. * @param target Defines the new target as a Vector or a mesh
  74843. */
  74844. setTarget(target: Vector3): void;
  74845. /**
  74846. * Return the current target position of the camera. This value is expressed in local space.
  74847. * @returns the target position
  74848. */
  74849. getTarget(): Vector3;
  74850. /** @hidden */
  74851. _decideIfNeedsToMove(): boolean;
  74852. /** @hidden */
  74853. _updatePosition(): void;
  74854. /** @hidden */
  74855. _checkInputs(): void;
  74856. protected _updateCameraRotationMatrix(): void;
  74857. /**
  74858. * 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)
  74859. * @returns the current camera
  74860. */
  74861. private _rotateUpVectorWithCameraRotationMatrix;
  74862. private _cachedRotationZ;
  74863. private _cachedQuaternionRotationZ;
  74864. /** @hidden */
  74865. _getViewMatrix(): Matrix;
  74866. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  74867. /**
  74868. * @hidden
  74869. */
  74870. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  74871. /**
  74872. * @hidden
  74873. */
  74874. _updateRigCameras(): void;
  74875. private _getRigCamPositionAndTarget;
  74876. /**
  74877. * Gets the current object class name.
  74878. * @return the class name
  74879. */
  74880. getClassName(): string;
  74881. }
  74882. }
  74883. declare module BABYLON {
  74884. /**
  74885. * Gather the list of keyboard event types as constants.
  74886. */
  74887. export class KeyboardEventTypes {
  74888. /**
  74889. * The keydown event is fired when a key becomes active (pressed).
  74890. */
  74891. static readonly KEYDOWN: number;
  74892. /**
  74893. * The keyup event is fired when a key has been released.
  74894. */
  74895. static readonly KEYUP: number;
  74896. }
  74897. /**
  74898. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74899. */
  74900. export class KeyboardInfo {
  74901. /**
  74902. * Defines the type of event (KeyboardEventTypes)
  74903. */
  74904. type: number;
  74905. /**
  74906. * Defines the related dom event
  74907. */
  74908. event: KeyboardEvent;
  74909. /**
  74910. * Instantiates a new keyboard info.
  74911. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74912. * @param type Defines the type of event (KeyboardEventTypes)
  74913. * @param event Defines the related dom event
  74914. */
  74915. constructor(
  74916. /**
  74917. * Defines the type of event (KeyboardEventTypes)
  74918. */
  74919. type: number,
  74920. /**
  74921. * Defines the related dom event
  74922. */
  74923. event: KeyboardEvent);
  74924. }
  74925. /**
  74926. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74927. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  74928. */
  74929. export class KeyboardInfoPre extends KeyboardInfo {
  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. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  74940. */
  74941. skipOnPointerObservable: boolean;
  74942. /**
  74943. * Instantiates a new keyboard pre info.
  74944. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74945. * @param type Defines the type of event (KeyboardEventTypes)
  74946. * @param event Defines the related dom event
  74947. */
  74948. constructor(
  74949. /**
  74950. * Defines the type of event (KeyboardEventTypes)
  74951. */
  74952. type: number,
  74953. /**
  74954. * Defines the related dom event
  74955. */
  74956. event: KeyboardEvent);
  74957. }
  74958. }
  74959. declare module BABYLON {
  74960. /**
  74961. * Manage the keyboard inputs to control the movement of a free camera.
  74962. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74963. */
  74964. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  74965. /**
  74966. * Defines the camera the input is attached to.
  74967. */
  74968. camera: FreeCamera;
  74969. /**
  74970. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  74971. */
  74972. keysUp: number[];
  74973. /**
  74974. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  74975. */
  74976. keysDown: number[];
  74977. /**
  74978. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  74979. */
  74980. keysLeft: number[];
  74981. /**
  74982. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  74983. */
  74984. keysRight: number[];
  74985. private _keys;
  74986. private _onCanvasBlurObserver;
  74987. private _onKeyboardObserver;
  74988. private _engine;
  74989. private _scene;
  74990. /**
  74991. * Attach the input controls to a specific dom element to get the input from.
  74992. * @param element Defines the element the controls should be listened from
  74993. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74994. */
  74995. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74996. /**
  74997. * Detach the current controls from the specified dom element.
  74998. * @param element Defines the element to stop listening the inputs from
  74999. */
  75000. detachControl(element: Nullable<HTMLElement>): void;
  75001. /**
  75002. * Update the current camera state depending on the inputs that have been used this frame.
  75003. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75004. */
  75005. checkInputs(): void;
  75006. /**
  75007. * Gets the class name of the current intput.
  75008. * @returns the class name
  75009. */
  75010. getClassName(): string;
  75011. /** @hidden */
  75012. _onLostFocus(): void;
  75013. /**
  75014. * Get the friendly name associated with the input class.
  75015. * @returns the input friendly name
  75016. */
  75017. getSimpleName(): string;
  75018. }
  75019. }
  75020. declare module BABYLON {
  75021. /**
  75022. * Interface describing all the common properties and methods a shadow light needs to implement.
  75023. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  75024. * as well as binding the different shadow properties to the effects.
  75025. */
  75026. export interface IShadowLight extends Light {
  75027. /**
  75028. * The light id in the scene (used in scene.findLighById for instance)
  75029. */
  75030. id: string;
  75031. /**
  75032. * The position the shdow will be casted from.
  75033. */
  75034. position: Vector3;
  75035. /**
  75036. * In 2d mode (needCube being false), the direction used to cast the shadow.
  75037. */
  75038. direction: Vector3;
  75039. /**
  75040. * The transformed position. Position of the light in world space taking parenting in account.
  75041. */
  75042. transformedPosition: Vector3;
  75043. /**
  75044. * The transformed direction. Direction of the light in world space taking parenting in account.
  75045. */
  75046. transformedDirection: Vector3;
  75047. /**
  75048. * The friendly name of the light in the scene.
  75049. */
  75050. name: string;
  75051. /**
  75052. * Defines the shadow projection clipping minimum z value.
  75053. */
  75054. shadowMinZ: number;
  75055. /**
  75056. * Defines the shadow projection clipping maximum z value.
  75057. */
  75058. shadowMaxZ: number;
  75059. /**
  75060. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75061. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75062. */
  75063. computeTransformedInformation(): boolean;
  75064. /**
  75065. * Gets the scene the light belongs to.
  75066. * @returns The scene
  75067. */
  75068. getScene(): Scene;
  75069. /**
  75070. * Callback defining a custom Projection Matrix Builder.
  75071. * This can be used to override the default projection matrix computation.
  75072. */
  75073. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75074. /**
  75075. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75076. * @param matrix The materix to updated with the projection information
  75077. * @param viewMatrix The transform matrix of the light
  75078. * @param renderList The list of mesh to render in the map
  75079. * @returns The current light
  75080. */
  75081. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75082. /**
  75083. * Gets the current depth scale used in ESM.
  75084. * @returns The scale
  75085. */
  75086. getDepthScale(): number;
  75087. /**
  75088. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75089. * @returns true if a cube texture needs to be use
  75090. */
  75091. needCube(): boolean;
  75092. /**
  75093. * Detects if the projection matrix requires to be recomputed this frame.
  75094. * @returns true if it requires to be recomputed otherwise, false.
  75095. */
  75096. needProjectionMatrixCompute(): boolean;
  75097. /**
  75098. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75099. */
  75100. forceProjectionMatrixCompute(): void;
  75101. /**
  75102. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75103. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75104. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75105. */
  75106. getShadowDirection(faceIndex?: number): Vector3;
  75107. /**
  75108. * Gets the minZ used for shadow according to both the scene and the light.
  75109. * @param activeCamera The camera we are returning the min for
  75110. * @returns the depth min z
  75111. */
  75112. getDepthMinZ(activeCamera: Camera): number;
  75113. /**
  75114. * Gets the maxZ used for shadow according to both the scene and the light.
  75115. * @param activeCamera The camera we are returning the max for
  75116. * @returns the depth max z
  75117. */
  75118. getDepthMaxZ(activeCamera: Camera): number;
  75119. }
  75120. /**
  75121. * Base implementation IShadowLight
  75122. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  75123. */
  75124. export abstract class ShadowLight extends Light implements IShadowLight {
  75125. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  75126. protected _position: Vector3;
  75127. protected _setPosition(value: Vector3): void;
  75128. /**
  75129. * Sets the position the shadow will be casted from. Also use as the light position for both
  75130. * point and spot lights.
  75131. */
  75132. /**
  75133. * Sets the position the shadow will be casted from. Also use as the light position for both
  75134. * point and spot lights.
  75135. */
  75136. position: Vector3;
  75137. protected _direction: Vector3;
  75138. protected _setDirection(value: Vector3): void;
  75139. /**
  75140. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  75141. * Also use as the light direction on spot and directional lights.
  75142. */
  75143. /**
  75144. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  75145. * Also use as the light direction on spot and directional lights.
  75146. */
  75147. direction: Vector3;
  75148. private _shadowMinZ;
  75149. /**
  75150. * Gets the shadow projection clipping minimum z value.
  75151. */
  75152. /**
  75153. * Sets the shadow projection clipping minimum z value.
  75154. */
  75155. shadowMinZ: number;
  75156. private _shadowMaxZ;
  75157. /**
  75158. * Sets the shadow projection clipping maximum z value.
  75159. */
  75160. /**
  75161. * Gets the shadow projection clipping maximum z value.
  75162. */
  75163. shadowMaxZ: number;
  75164. /**
  75165. * Callback defining a custom Projection Matrix Builder.
  75166. * This can be used to override the default projection matrix computation.
  75167. */
  75168. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75169. /**
  75170. * The transformed position. Position of the light in world space taking parenting in account.
  75171. */
  75172. transformedPosition: Vector3;
  75173. /**
  75174. * The transformed direction. Direction of the light in world space taking parenting in account.
  75175. */
  75176. transformedDirection: Vector3;
  75177. private _needProjectionMatrixCompute;
  75178. /**
  75179. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75180. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75181. */
  75182. computeTransformedInformation(): boolean;
  75183. /**
  75184. * Return the depth scale used for the shadow map.
  75185. * @returns the depth scale.
  75186. */
  75187. getDepthScale(): number;
  75188. /**
  75189. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75190. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75191. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75192. */
  75193. getShadowDirection(faceIndex?: number): Vector3;
  75194. /**
  75195. * Returns the ShadowLight absolute position in the World.
  75196. * @returns the position vector in world space
  75197. */
  75198. getAbsolutePosition(): Vector3;
  75199. /**
  75200. * Sets the ShadowLight direction toward the passed target.
  75201. * @param target The point to target in local space
  75202. * @returns the updated ShadowLight direction
  75203. */
  75204. setDirectionToTarget(target: Vector3): Vector3;
  75205. /**
  75206. * Returns the light rotation in euler definition.
  75207. * @returns the x y z rotation in local space.
  75208. */
  75209. getRotation(): Vector3;
  75210. /**
  75211. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75212. * @returns true if a cube texture needs to be use
  75213. */
  75214. needCube(): boolean;
  75215. /**
  75216. * Detects if the projection matrix requires to be recomputed this frame.
  75217. * @returns true if it requires to be recomputed otherwise, false.
  75218. */
  75219. needProjectionMatrixCompute(): boolean;
  75220. /**
  75221. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75222. */
  75223. forceProjectionMatrixCompute(): void;
  75224. /** @hidden */
  75225. _initCache(): void;
  75226. /** @hidden */
  75227. _isSynchronized(): boolean;
  75228. /**
  75229. * Computes the world matrix of the node
  75230. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  75231. * @returns the world matrix
  75232. */
  75233. computeWorldMatrix(force?: boolean): Matrix;
  75234. /**
  75235. * Gets the minZ used for shadow according to both the scene and the light.
  75236. * @param activeCamera The camera we are returning the min for
  75237. * @returns the depth min z
  75238. */
  75239. getDepthMinZ(activeCamera: Camera): number;
  75240. /**
  75241. * Gets the maxZ used for shadow according to both the scene and the light.
  75242. * @param activeCamera The camera we are returning the max for
  75243. * @returns the depth max z
  75244. */
  75245. getDepthMaxZ(activeCamera: Camera): number;
  75246. /**
  75247. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75248. * @param matrix The materix to updated with the projection information
  75249. * @param viewMatrix The transform matrix of the light
  75250. * @param renderList The list of mesh to render in the map
  75251. * @returns The current light
  75252. */
  75253. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75254. }
  75255. }
  75256. declare module BABYLON {
  75257. /**
  75258. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  75259. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  75260. */
  75261. export class EffectFallbacks implements IEffectFallbacks {
  75262. private _defines;
  75263. private _currentRank;
  75264. private _maxRank;
  75265. private _mesh;
  75266. /**
  75267. * Removes the fallback from the bound mesh.
  75268. */
  75269. unBindMesh(): void;
  75270. /**
  75271. * Adds a fallback on the specified property.
  75272. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75273. * @param define The name of the define in the shader
  75274. */
  75275. addFallback(rank: number, define: string): void;
  75276. /**
  75277. * Sets the mesh to use CPU skinning when needing to fallback.
  75278. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75279. * @param mesh The mesh to use the fallbacks.
  75280. */
  75281. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  75282. /**
  75283. * Checks to see if more fallbacks are still availible.
  75284. */
  75285. readonly hasMoreFallbacks: boolean;
  75286. /**
  75287. * Removes the defines that should be removed when falling back.
  75288. * @param currentDefines defines the current define statements for the shader.
  75289. * @param effect defines the current effect we try to compile
  75290. * @returns The resulting defines with defines of the current rank removed.
  75291. */
  75292. reduce(currentDefines: string, effect: Effect): string;
  75293. }
  75294. }
  75295. declare module BABYLON {
  75296. /**
  75297. * "Static Class" containing the most commonly used helper while dealing with material for
  75298. * rendering purpose.
  75299. *
  75300. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  75301. *
  75302. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  75303. */
  75304. export class MaterialHelper {
  75305. /**
  75306. * Bind the current view position to an effect.
  75307. * @param effect The effect to be bound
  75308. * @param scene The scene the eyes position is used from
  75309. */
  75310. static BindEyePosition(effect: Effect, scene: Scene): void;
  75311. /**
  75312. * Helps preparing the defines values about the UVs in used in the effect.
  75313. * UVs are shared as much as we can accross channels in the shaders.
  75314. * @param texture The texture we are preparing the UVs for
  75315. * @param defines The defines to update
  75316. * @param key The channel key "diffuse", "specular"... used in the shader
  75317. */
  75318. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  75319. /**
  75320. * Binds a texture matrix value to its corrsponding uniform
  75321. * @param texture The texture to bind the matrix for
  75322. * @param uniformBuffer The uniform buffer receivin the data
  75323. * @param key The channel key "diffuse", "specular"... used in the shader
  75324. */
  75325. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  75326. /**
  75327. * Gets the current status of the fog (should it be enabled?)
  75328. * @param mesh defines the mesh to evaluate for fog support
  75329. * @param scene defines the hosting scene
  75330. * @returns true if fog must be enabled
  75331. */
  75332. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  75333. /**
  75334. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  75335. * @param mesh defines the current mesh
  75336. * @param scene defines the current scene
  75337. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  75338. * @param pointsCloud defines if point cloud rendering has to be turned on
  75339. * @param fogEnabled defines if fog has to be turned on
  75340. * @param alphaTest defines if alpha testing has to be turned on
  75341. * @param defines defines the current list of defines
  75342. */
  75343. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  75344. /**
  75345. * Helper used to prepare the list of defines associated with frame values for shader compilation
  75346. * @param scene defines the current scene
  75347. * @param engine defines the current engine
  75348. * @param defines specifies the list of active defines
  75349. * @param useInstances defines if instances have to be turned on
  75350. * @param useClipPlane defines if clip plane have to be turned on
  75351. */
  75352. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  75353. /**
  75354. * Prepares the defines for bones
  75355. * @param mesh The mesh containing the geometry data we will draw
  75356. * @param defines The defines to update
  75357. */
  75358. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  75359. /**
  75360. * Prepares the defines for morph targets
  75361. * @param mesh The mesh containing the geometry data we will draw
  75362. * @param defines The defines to update
  75363. */
  75364. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  75365. /**
  75366. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  75367. * @param mesh The mesh containing the geometry data we will draw
  75368. * @param defines The defines to update
  75369. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  75370. * @param useBones Precise whether bones should be used or not (override mesh info)
  75371. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  75372. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  75373. * @returns false if defines are considered not dirty and have not been checked
  75374. */
  75375. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  75376. /**
  75377. * Prepares the defines related to multiview
  75378. * @param scene The scene we are intending to draw
  75379. * @param defines The defines to update
  75380. */
  75381. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  75382. /**
  75383. * Prepares the defines related to the light information passed in parameter
  75384. * @param scene The scene we are intending to draw
  75385. * @param mesh The mesh the effect is compiling for
  75386. * @param light The light the effect is compiling for
  75387. * @param lightIndex The index of the light
  75388. * @param defines The defines to update
  75389. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75390. * @param state Defines the current state regarding what is needed (normals, etc...)
  75391. */
  75392. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  75393. needNormals: boolean;
  75394. needRebuild: boolean;
  75395. shadowEnabled: boolean;
  75396. specularEnabled: boolean;
  75397. lightmapMode: boolean;
  75398. }): void;
  75399. /**
  75400. * Prepares the defines related to the light information passed in parameter
  75401. * @param scene The scene we are intending to draw
  75402. * @param mesh The mesh the effect is compiling for
  75403. * @param defines The defines to update
  75404. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75405. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  75406. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  75407. * @returns true if normals will be required for the rest of the effect
  75408. */
  75409. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  75410. /**
  75411. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  75412. * @param lightIndex defines the light index
  75413. * @param uniformsList The uniform list
  75414. * @param samplersList The sampler list
  75415. * @param projectedLightTexture defines if projected texture must be used
  75416. * @param uniformBuffersList defines an optional list of uniform buffers
  75417. */
  75418. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  75419. /**
  75420. * Prepares the uniforms and samplers list to be used in the effect
  75421. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  75422. * @param samplersList The sampler list
  75423. * @param defines The defines helping in the list generation
  75424. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  75425. */
  75426. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  75427. /**
  75428. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  75429. * @param defines The defines to update while falling back
  75430. * @param fallbacks The authorized effect fallbacks
  75431. * @param maxSimultaneousLights The maximum number of lights allowed
  75432. * @param rank the current rank of the Effect
  75433. * @returns The newly affected rank
  75434. */
  75435. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  75436. private static _TmpMorphInfluencers;
  75437. /**
  75438. * Prepares the list of attributes required for morph targets according to the effect defines.
  75439. * @param attribs The current list of supported attribs
  75440. * @param mesh The mesh to prepare the morph targets attributes for
  75441. * @param influencers The number of influencers
  75442. */
  75443. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  75444. /**
  75445. * Prepares the list of attributes required for morph targets according to the effect defines.
  75446. * @param attribs The current list of supported attribs
  75447. * @param mesh The mesh to prepare the morph targets attributes for
  75448. * @param defines The current Defines of the effect
  75449. */
  75450. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  75451. /**
  75452. * Prepares the list of attributes required for bones according to the effect defines.
  75453. * @param attribs The current list of supported attribs
  75454. * @param mesh The mesh to prepare the bones attributes for
  75455. * @param defines The current Defines of the effect
  75456. * @param fallbacks The current efffect fallback strategy
  75457. */
  75458. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  75459. /**
  75460. * Check and prepare the list of attributes required for instances according to the effect defines.
  75461. * @param attribs The current list of supported attribs
  75462. * @param defines The current MaterialDefines of the effect
  75463. */
  75464. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  75465. /**
  75466. * Add the list of attributes required for instances to the attribs array.
  75467. * @param attribs The current list of supported attribs
  75468. */
  75469. static PushAttributesForInstances(attribs: string[]): void;
  75470. /**
  75471. * Binds the light shadow information to the effect for the given mesh.
  75472. * @param light The light containing the generator
  75473. * @param scene The scene the lights belongs to
  75474. * @param mesh The mesh we are binding the information to render
  75475. * @param lightIndex The light index in the effect used to render the mesh
  75476. * @param effect The effect we are binding the data to
  75477. */
  75478. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  75479. /**
  75480. * Binds the light information to the effect.
  75481. * @param light The light containing the generator
  75482. * @param effect The effect we are binding the data to
  75483. * @param lightIndex The light index in the effect used to render
  75484. */
  75485. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  75486. /**
  75487. * Binds the lights information from the scene to the effect for the given mesh.
  75488. * @param light Light to bind
  75489. * @param lightIndex Light index
  75490. * @param scene The scene where the light belongs to
  75491. * @param mesh The mesh we are binding the information to render
  75492. * @param effect The effect we are binding the data to
  75493. * @param useSpecular Defines if specular is supported
  75494. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75495. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75496. */
  75497. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75498. /**
  75499. * Binds the lights information from the scene to the effect for the given mesh.
  75500. * @param scene The scene the lights belongs to
  75501. * @param mesh The mesh we are binding the information to render
  75502. * @param effect The effect we are binding the data to
  75503. * @param defines The generated defines for the effect
  75504. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  75505. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75506. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75507. */
  75508. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75509. private static _tempFogColor;
  75510. /**
  75511. * Binds the fog information from the scene to the effect for the given mesh.
  75512. * @param scene The scene the lights belongs to
  75513. * @param mesh The mesh we are binding the information to render
  75514. * @param effect The effect we are binding the data to
  75515. * @param linearSpace Defines if the fog effect is applied in linear space
  75516. */
  75517. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  75518. /**
  75519. * Binds the bones information from the mesh to the effect.
  75520. * @param mesh The mesh we are binding the information to render
  75521. * @param effect The effect we are binding the data to
  75522. */
  75523. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  75524. /**
  75525. * Binds the morph targets information from the mesh to the effect.
  75526. * @param abstractMesh The mesh we are binding the information to render
  75527. * @param effect The effect we are binding the data to
  75528. */
  75529. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  75530. /**
  75531. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  75532. * @param defines The generated defines used in the effect
  75533. * @param effect The effect we are binding the data to
  75534. * @param scene The scene we are willing to render with logarithmic scale for
  75535. */
  75536. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  75537. /**
  75538. * Binds the clip plane information from the scene to the effect.
  75539. * @param scene The scene the clip plane information are extracted from
  75540. * @param effect The effect we are binding the data to
  75541. */
  75542. static BindClipPlane(effect: Effect, scene: Scene): void;
  75543. }
  75544. }
  75545. declare module BABYLON {
  75546. /** @hidden */
  75547. export var packingFunctions: {
  75548. name: string;
  75549. shader: string;
  75550. };
  75551. }
  75552. declare module BABYLON {
  75553. /** @hidden */
  75554. export var shadowMapPixelShader: {
  75555. name: string;
  75556. shader: string;
  75557. };
  75558. }
  75559. declare module BABYLON {
  75560. /** @hidden */
  75561. export var bonesDeclaration: {
  75562. name: string;
  75563. shader: string;
  75564. };
  75565. }
  75566. declare module BABYLON {
  75567. /** @hidden */
  75568. export var morphTargetsVertexGlobalDeclaration: {
  75569. name: string;
  75570. shader: string;
  75571. };
  75572. }
  75573. declare module BABYLON {
  75574. /** @hidden */
  75575. export var morphTargetsVertexDeclaration: {
  75576. name: string;
  75577. shader: string;
  75578. };
  75579. }
  75580. declare module BABYLON {
  75581. /** @hidden */
  75582. export var instancesDeclaration: {
  75583. name: string;
  75584. shader: string;
  75585. };
  75586. }
  75587. declare module BABYLON {
  75588. /** @hidden */
  75589. export var helperFunctions: {
  75590. name: string;
  75591. shader: string;
  75592. };
  75593. }
  75594. declare module BABYLON {
  75595. /** @hidden */
  75596. export var morphTargetsVertex: {
  75597. name: string;
  75598. shader: string;
  75599. };
  75600. }
  75601. declare module BABYLON {
  75602. /** @hidden */
  75603. export var instancesVertex: {
  75604. name: string;
  75605. shader: string;
  75606. };
  75607. }
  75608. declare module BABYLON {
  75609. /** @hidden */
  75610. export var bonesVertex: {
  75611. name: string;
  75612. shader: string;
  75613. };
  75614. }
  75615. declare module BABYLON {
  75616. /** @hidden */
  75617. export var shadowMapVertexShader: {
  75618. name: string;
  75619. shader: string;
  75620. };
  75621. }
  75622. declare module BABYLON {
  75623. /** @hidden */
  75624. export var depthBoxBlurPixelShader: {
  75625. name: string;
  75626. shader: string;
  75627. };
  75628. }
  75629. declare module BABYLON {
  75630. /**
  75631. * Defines the options associated with the creation of a custom shader for a shadow generator.
  75632. */
  75633. export interface ICustomShaderOptions {
  75634. /**
  75635. * Gets or sets the custom shader name to use
  75636. */
  75637. shaderName: string;
  75638. /**
  75639. * The list of attribute names used in the shader
  75640. */
  75641. attributes?: string[];
  75642. /**
  75643. * The list of unifrom names used in the shader
  75644. */
  75645. uniforms?: string[];
  75646. /**
  75647. * The list of sampler names used in the shader
  75648. */
  75649. samplers?: string[];
  75650. /**
  75651. * The list of defines used in the shader
  75652. */
  75653. defines?: string[];
  75654. }
  75655. /**
  75656. * Interface to implement to create a shadow generator compatible with BJS.
  75657. */
  75658. export interface IShadowGenerator {
  75659. /**
  75660. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75661. * @returns The render target texture if present otherwise, null
  75662. */
  75663. getShadowMap(): Nullable<RenderTargetTexture>;
  75664. /**
  75665. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75666. * @returns The render target texture if the shadow map is present otherwise, null
  75667. */
  75668. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75669. /**
  75670. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75671. * @param subMesh The submesh we want to render in the shadow map
  75672. * @param useInstances Defines wether will draw in the map using instances
  75673. * @returns true if ready otherwise, false
  75674. */
  75675. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75676. /**
  75677. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75678. * @param defines Defines of the material we want to update
  75679. * @param lightIndex Index of the light in the enabled light list of the material
  75680. */
  75681. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  75682. /**
  75683. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75684. * defined in the generator but impacting the effect).
  75685. * It implies the unifroms available on the materials are the standard BJS ones.
  75686. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75687. * @param effect The effect we are binfing the information for
  75688. */
  75689. bindShadowLight(lightIndex: string, effect: Effect): void;
  75690. /**
  75691. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  75692. * (eq to shadow prjection matrix * light transform matrix)
  75693. * @returns The transform matrix used to create the shadow map
  75694. */
  75695. getTransformMatrix(): Matrix;
  75696. /**
  75697. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  75698. * Cube and 2D textures for instance.
  75699. */
  75700. recreateShadowMap(): void;
  75701. /**
  75702. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75703. * @param onCompiled Callback triggered at the and of the effects compilation
  75704. * @param options Sets of optional options forcing the compilation with different modes
  75705. */
  75706. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  75707. useInstances: boolean;
  75708. }>): void;
  75709. /**
  75710. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75711. * @param options Sets of optional options forcing the compilation with different modes
  75712. * @returns A promise that resolves when the compilation completes
  75713. */
  75714. forceCompilationAsync(options?: Partial<{
  75715. useInstances: boolean;
  75716. }>): Promise<void>;
  75717. /**
  75718. * Serializes the shadow generator setup to a json object.
  75719. * @returns The serialized JSON object
  75720. */
  75721. serialize(): any;
  75722. /**
  75723. * Disposes the Shadow map and related Textures and effects.
  75724. */
  75725. dispose(): void;
  75726. }
  75727. /**
  75728. * Default implementation IShadowGenerator.
  75729. * This is the main object responsible of generating shadows in the framework.
  75730. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  75731. */
  75732. export class ShadowGenerator implements IShadowGenerator {
  75733. /**
  75734. * Shadow generator mode None: no filtering applied.
  75735. */
  75736. static readonly FILTER_NONE: number;
  75737. /**
  75738. * Shadow generator mode ESM: Exponential Shadow Mapping.
  75739. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75740. */
  75741. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  75742. /**
  75743. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  75744. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  75745. */
  75746. static readonly FILTER_POISSONSAMPLING: number;
  75747. /**
  75748. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  75749. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75750. */
  75751. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  75752. /**
  75753. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  75754. * edge artifacts on steep falloff.
  75755. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75756. */
  75757. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  75758. /**
  75759. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  75760. * edge artifacts on steep falloff.
  75761. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75762. */
  75763. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  75764. /**
  75765. * Shadow generator mode PCF: Percentage Closer Filtering
  75766. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75767. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  75768. */
  75769. static readonly FILTER_PCF: number;
  75770. /**
  75771. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  75772. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75773. * Contact Hardening
  75774. */
  75775. static readonly FILTER_PCSS: number;
  75776. /**
  75777. * Reserved for PCF and PCSS
  75778. * Highest Quality.
  75779. *
  75780. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  75781. *
  75782. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  75783. */
  75784. static readonly QUALITY_HIGH: number;
  75785. /**
  75786. * Reserved for PCF and PCSS
  75787. * Good tradeoff for quality/perf cross devices
  75788. *
  75789. * Execute PCF on a 3*3 kernel.
  75790. *
  75791. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  75792. */
  75793. static readonly QUALITY_MEDIUM: number;
  75794. /**
  75795. * Reserved for PCF and PCSS
  75796. * The lowest quality but the fastest.
  75797. *
  75798. * Execute PCF on a 1*1 kernel.
  75799. *
  75800. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  75801. */
  75802. static readonly QUALITY_LOW: number;
  75803. /** Gets or sets the custom shader name to use */
  75804. customShaderOptions: ICustomShaderOptions;
  75805. /**
  75806. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  75807. */
  75808. onBeforeShadowMapRenderObservable: Observable<Effect>;
  75809. /**
  75810. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  75811. */
  75812. onAfterShadowMapRenderObservable: Observable<Effect>;
  75813. /**
  75814. * Observable triggered before a mesh is rendered in the shadow map.
  75815. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  75816. */
  75817. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  75818. /**
  75819. * Observable triggered after a mesh is rendered in the shadow map.
  75820. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  75821. */
  75822. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  75823. private _bias;
  75824. /**
  75825. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  75826. */
  75827. /**
  75828. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  75829. */
  75830. bias: number;
  75831. private _normalBias;
  75832. /**
  75833. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75834. */
  75835. /**
  75836. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75837. */
  75838. normalBias: number;
  75839. private _blurBoxOffset;
  75840. /**
  75841. * Gets the blur box offset: offset applied during the blur pass.
  75842. * Only useful if useKernelBlur = false
  75843. */
  75844. /**
  75845. * Sets the blur box offset: offset applied during the blur pass.
  75846. * Only useful if useKernelBlur = false
  75847. */
  75848. blurBoxOffset: number;
  75849. private _blurScale;
  75850. /**
  75851. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  75852. * 2 means half of the size.
  75853. */
  75854. /**
  75855. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  75856. * 2 means half of the size.
  75857. */
  75858. blurScale: number;
  75859. private _blurKernel;
  75860. /**
  75861. * Gets the blur kernel: kernel size of the blur pass.
  75862. * Only useful if useKernelBlur = true
  75863. */
  75864. /**
  75865. * Sets the blur kernel: kernel size of the blur pass.
  75866. * Only useful if useKernelBlur = true
  75867. */
  75868. blurKernel: number;
  75869. private _useKernelBlur;
  75870. /**
  75871. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  75872. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75873. */
  75874. /**
  75875. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  75876. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75877. */
  75878. useKernelBlur: boolean;
  75879. private _depthScale;
  75880. /**
  75881. * Gets the depth scale used in ESM mode.
  75882. */
  75883. /**
  75884. * Sets the depth scale used in ESM mode.
  75885. * This can override the scale stored on the light.
  75886. */
  75887. depthScale: number;
  75888. private _filter;
  75889. /**
  75890. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  75891. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75892. */
  75893. /**
  75894. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  75895. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75896. */
  75897. filter: number;
  75898. /**
  75899. * Gets if the current filter is set to Poisson Sampling.
  75900. */
  75901. /**
  75902. * Sets the current filter to Poisson Sampling.
  75903. */
  75904. usePoissonSampling: boolean;
  75905. /**
  75906. * Gets if the current filter is set to ESM.
  75907. */
  75908. /**
  75909. * Sets the current filter is to ESM.
  75910. */
  75911. useExponentialShadowMap: boolean;
  75912. /**
  75913. * Gets if the current filter is set to filtered ESM.
  75914. */
  75915. /**
  75916. * Gets if the current filter is set to filtered ESM.
  75917. */
  75918. useBlurExponentialShadowMap: boolean;
  75919. /**
  75920. * Gets if the current filter is set to "close ESM" (using the inverse of the
  75921. * exponential to prevent steep falloff artifacts).
  75922. */
  75923. /**
  75924. * Sets the current filter to "close ESM" (using the inverse of the
  75925. * exponential to prevent steep falloff artifacts).
  75926. */
  75927. useCloseExponentialShadowMap: boolean;
  75928. /**
  75929. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  75930. * exponential to prevent steep falloff artifacts).
  75931. */
  75932. /**
  75933. * Sets the current filter to filtered "close ESM" (using the inverse of the
  75934. * exponential to prevent steep falloff artifacts).
  75935. */
  75936. useBlurCloseExponentialShadowMap: boolean;
  75937. /**
  75938. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  75939. */
  75940. /**
  75941. * Sets the current filter to "PCF" (percentage closer filtering).
  75942. */
  75943. usePercentageCloserFiltering: boolean;
  75944. private _filteringQuality;
  75945. /**
  75946. * Gets the PCF or PCSS Quality.
  75947. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75948. */
  75949. /**
  75950. * Sets the PCF or PCSS Quality.
  75951. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75952. */
  75953. filteringQuality: number;
  75954. /**
  75955. * Gets if the current filter is set to "PCSS" (contact hardening).
  75956. */
  75957. /**
  75958. * Sets the current filter to "PCSS" (contact hardening).
  75959. */
  75960. useContactHardeningShadow: boolean;
  75961. private _contactHardeningLightSizeUVRatio;
  75962. /**
  75963. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75964. * Using a ratio helps keeping shape stability independently of the map size.
  75965. *
  75966. * It does not account for the light projection as it was having too much
  75967. * instability during the light setup or during light position changes.
  75968. *
  75969. * Only valid if useContactHardeningShadow is true.
  75970. */
  75971. /**
  75972. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75973. * Using a ratio helps keeping shape stability independently of the map size.
  75974. *
  75975. * It does not account for the light projection as it was having too much
  75976. * instability during the light setup or during light position changes.
  75977. *
  75978. * Only valid if useContactHardeningShadow is true.
  75979. */
  75980. contactHardeningLightSizeUVRatio: number;
  75981. private _darkness;
  75982. /** Gets or sets the actual darkness of a shadow */
  75983. darkness: number;
  75984. /**
  75985. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  75986. * 0 means strongest and 1 would means no shadow.
  75987. * @returns the darkness.
  75988. */
  75989. getDarkness(): number;
  75990. /**
  75991. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  75992. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  75993. * @returns the shadow generator allowing fluent coding.
  75994. */
  75995. setDarkness(darkness: number): ShadowGenerator;
  75996. private _transparencyShadow;
  75997. /** Gets or sets the ability to have transparent shadow */
  75998. transparencyShadow: boolean;
  75999. /**
  76000. * Sets the ability to have transparent shadow (boolean).
  76001. * @param transparent True if transparent else False
  76002. * @returns the shadow generator allowing fluent coding
  76003. */
  76004. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  76005. private _shadowMap;
  76006. private _shadowMap2;
  76007. /**
  76008. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76009. * @returns The render target texture if present otherwise, null
  76010. */
  76011. getShadowMap(): Nullable<RenderTargetTexture>;
  76012. /**
  76013. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76014. * @returns The render target texture if the shadow map is present otherwise, null
  76015. */
  76016. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76017. /**
  76018. * Gets the class name of that object
  76019. * @returns "ShadowGenerator"
  76020. */
  76021. getClassName(): string;
  76022. /**
  76023. * Helper function to add a mesh and its descendants to the list of shadow casters.
  76024. * @param mesh Mesh to add
  76025. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  76026. * @returns the Shadow Generator itself
  76027. */
  76028. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76029. /**
  76030. * Helper function to remove a mesh and its descendants from the list of shadow casters
  76031. * @param mesh Mesh to remove
  76032. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  76033. * @returns the Shadow Generator itself
  76034. */
  76035. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76036. /**
  76037. * Controls the extent to which the shadows fade out at the edge of the frustum
  76038. * Used only by directionals and spots
  76039. */
  76040. frustumEdgeFalloff: number;
  76041. private _light;
  76042. /**
  76043. * Returns the associated light object.
  76044. * @returns the light generating the shadow
  76045. */
  76046. getLight(): IShadowLight;
  76047. /**
  76048. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  76049. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  76050. * It might on the other hand introduce peter panning.
  76051. */
  76052. forceBackFacesOnly: boolean;
  76053. private _scene;
  76054. private _lightDirection;
  76055. private _effect;
  76056. private _viewMatrix;
  76057. private _projectionMatrix;
  76058. private _transformMatrix;
  76059. private _cachedPosition;
  76060. private _cachedDirection;
  76061. private _cachedDefines;
  76062. private _currentRenderID;
  76063. private _boxBlurPostprocess;
  76064. private _kernelBlurXPostprocess;
  76065. private _kernelBlurYPostprocess;
  76066. private _blurPostProcesses;
  76067. private _mapSize;
  76068. private _currentFaceIndex;
  76069. private _currentFaceIndexCache;
  76070. private _textureType;
  76071. private _defaultTextureMatrix;
  76072. /** @hidden */
  76073. static _SceneComponentInitialization: (scene: Scene) => void;
  76074. /**
  76075. * Creates a ShadowGenerator object.
  76076. * A ShadowGenerator is the required tool to use the shadows.
  76077. * Each light casting shadows needs to use its own ShadowGenerator.
  76078. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  76079. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  76080. * @param light The light object generating the shadows.
  76081. * @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.
  76082. */
  76083. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  76084. private _initializeGenerator;
  76085. private _initializeShadowMap;
  76086. private _initializeBlurRTTAndPostProcesses;
  76087. private _renderForShadowMap;
  76088. private _renderSubMeshForShadowMap;
  76089. private _applyFilterValues;
  76090. /**
  76091. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76092. * @param onCompiled Callback triggered at the and of the effects compilation
  76093. * @param options Sets of optional options forcing the compilation with different modes
  76094. */
  76095. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76096. useInstances: boolean;
  76097. }>): void;
  76098. /**
  76099. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76100. * @param options Sets of optional options forcing the compilation with different modes
  76101. * @returns A promise that resolves when the compilation completes
  76102. */
  76103. forceCompilationAsync(options?: Partial<{
  76104. useInstances: boolean;
  76105. }>): Promise<void>;
  76106. /**
  76107. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76108. * @param subMesh The submesh we want to render in the shadow map
  76109. * @param useInstances Defines wether will draw in the map using instances
  76110. * @returns true if ready otherwise, false
  76111. */
  76112. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76113. /**
  76114. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76115. * @param defines Defines of the material we want to update
  76116. * @param lightIndex Index of the light in the enabled light list of the material
  76117. */
  76118. prepareDefines(defines: any, lightIndex: number): void;
  76119. /**
  76120. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76121. * defined in the generator but impacting the effect).
  76122. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76123. * @param effect The effect we are binfing the information for
  76124. */
  76125. bindShadowLight(lightIndex: string, effect: Effect): void;
  76126. /**
  76127. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76128. * (eq to shadow prjection matrix * light transform matrix)
  76129. * @returns The transform matrix used to create the shadow map
  76130. */
  76131. getTransformMatrix(): Matrix;
  76132. /**
  76133. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76134. * Cube and 2D textures for instance.
  76135. */
  76136. recreateShadowMap(): void;
  76137. private _disposeBlurPostProcesses;
  76138. private _disposeRTTandPostProcesses;
  76139. /**
  76140. * Disposes the ShadowGenerator.
  76141. * Returns nothing.
  76142. */
  76143. dispose(): void;
  76144. /**
  76145. * Serializes the shadow generator setup to a json object.
  76146. * @returns The serialized JSON object
  76147. */
  76148. serialize(): any;
  76149. /**
  76150. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  76151. * @param parsedShadowGenerator The JSON object to parse
  76152. * @param scene The scene to create the shadow map for
  76153. * @returns The parsed shadow generator
  76154. */
  76155. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  76156. }
  76157. }
  76158. declare module BABYLON {
  76159. /**
  76160. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  76161. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  76162. * 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.
  76163. */
  76164. export abstract class Light extends Node {
  76165. /**
  76166. * Falloff Default: light is falling off following the material specification:
  76167. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  76168. */
  76169. static readonly FALLOFF_DEFAULT: number;
  76170. /**
  76171. * Falloff Physical: light is falling off following the inverse squared distance law.
  76172. */
  76173. static readonly FALLOFF_PHYSICAL: number;
  76174. /**
  76175. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  76176. * to enhance interoperability with other engines.
  76177. */
  76178. static readonly FALLOFF_GLTF: number;
  76179. /**
  76180. * Falloff Standard: light is falling off like in the standard material
  76181. * to enhance interoperability with other materials.
  76182. */
  76183. static readonly FALLOFF_STANDARD: number;
  76184. /**
  76185. * If every light affecting the material is in this lightmapMode,
  76186. * material.lightmapTexture adds or multiplies
  76187. * (depends on material.useLightmapAsShadowmap)
  76188. * after every other light calculations.
  76189. */
  76190. static readonly LIGHTMAP_DEFAULT: number;
  76191. /**
  76192. * material.lightmapTexture as only diffuse lighting from this light
  76193. * adds only specular lighting from this light
  76194. * adds dynamic shadows
  76195. */
  76196. static readonly LIGHTMAP_SPECULAR: number;
  76197. /**
  76198. * material.lightmapTexture as only lighting
  76199. * no light calculation from this light
  76200. * only adds dynamic shadows from this light
  76201. */
  76202. static readonly LIGHTMAP_SHADOWSONLY: number;
  76203. /**
  76204. * Each light type uses the default quantity according to its type:
  76205. * point/spot lights use luminous intensity
  76206. * directional lights use illuminance
  76207. */
  76208. static readonly INTENSITYMODE_AUTOMATIC: number;
  76209. /**
  76210. * lumen (lm)
  76211. */
  76212. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  76213. /**
  76214. * candela (lm/sr)
  76215. */
  76216. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  76217. /**
  76218. * lux (lm/m^2)
  76219. */
  76220. static readonly INTENSITYMODE_ILLUMINANCE: number;
  76221. /**
  76222. * nit (cd/m^2)
  76223. */
  76224. static readonly INTENSITYMODE_LUMINANCE: number;
  76225. /**
  76226. * Light type const id of the point light.
  76227. */
  76228. static readonly LIGHTTYPEID_POINTLIGHT: number;
  76229. /**
  76230. * Light type const id of the directional light.
  76231. */
  76232. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  76233. /**
  76234. * Light type const id of the spot light.
  76235. */
  76236. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  76237. /**
  76238. * Light type const id of the hemispheric light.
  76239. */
  76240. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  76241. /**
  76242. * Diffuse gives the basic color to an object.
  76243. */
  76244. diffuse: Color3;
  76245. /**
  76246. * Specular produces a highlight color on an object.
  76247. * Note: This is note affecting PBR materials.
  76248. */
  76249. specular: Color3;
  76250. /**
  76251. * Defines the falloff type for this light. This lets overrriding how punctual light are
  76252. * falling off base on range or angle.
  76253. * This can be set to any values in Light.FALLOFF_x.
  76254. *
  76255. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  76256. * other types of materials.
  76257. */
  76258. falloffType: number;
  76259. /**
  76260. * Strength of the light.
  76261. * Note: By default it is define in the framework own unit.
  76262. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  76263. */
  76264. intensity: number;
  76265. private _range;
  76266. protected _inverseSquaredRange: number;
  76267. /**
  76268. * Defines how far from the source the light is impacting in scene units.
  76269. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76270. */
  76271. /**
  76272. * Defines how far from the source the light is impacting in scene units.
  76273. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76274. */
  76275. range: number;
  76276. /**
  76277. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  76278. * of light.
  76279. */
  76280. private _photometricScale;
  76281. private _intensityMode;
  76282. /**
  76283. * Gets the photometric scale used to interpret the intensity.
  76284. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76285. */
  76286. /**
  76287. * Sets the photometric scale used to interpret the intensity.
  76288. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76289. */
  76290. intensityMode: number;
  76291. private _radius;
  76292. /**
  76293. * Gets the light radius used by PBR Materials to simulate soft area lights.
  76294. */
  76295. /**
  76296. * sets the light radius used by PBR Materials to simulate soft area lights.
  76297. */
  76298. radius: number;
  76299. private _renderPriority;
  76300. /**
  76301. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  76302. * exceeding the number allowed of the materials.
  76303. */
  76304. renderPriority: number;
  76305. private _shadowEnabled;
  76306. /**
  76307. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76308. * the current shadow generator.
  76309. */
  76310. /**
  76311. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76312. * the current shadow generator.
  76313. */
  76314. shadowEnabled: boolean;
  76315. private _includedOnlyMeshes;
  76316. /**
  76317. * Gets the only meshes impacted by this light.
  76318. */
  76319. /**
  76320. * Sets the only meshes impacted by this light.
  76321. */
  76322. includedOnlyMeshes: AbstractMesh[];
  76323. private _excludedMeshes;
  76324. /**
  76325. * Gets the meshes not impacted by this light.
  76326. */
  76327. /**
  76328. * Sets the meshes not impacted by this light.
  76329. */
  76330. excludedMeshes: AbstractMesh[];
  76331. private _excludeWithLayerMask;
  76332. /**
  76333. * Gets the layer id use to find what meshes are not impacted by the light.
  76334. * Inactive if 0
  76335. */
  76336. /**
  76337. * Sets the layer id use to find what meshes are not impacted by the light.
  76338. * Inactive if 0
  76339. */
  76340. excludeWithLayerMask: number;
  76341. private _includeOnlyWithLayerMask;
  76342. /**
  76343. * Gets the layer id use to find what meshes are impacted by the light.
  76344. * Inactive if 0
  76345. */
  76346. /**
  76347. * Sets the layer id use to find what meshes are impacted by the light.
  76348. * Inactive if 0
  76349. */
  76350. includeOnlyWithLayerMask: number;
  76351. private _lightmapMode;
  76352. /**
  76353. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76354. */
  76355. /**
  76356. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76357. */
  76358. lightmapMode: number;
  76359. /**
  76360. * Shadow generator associted to the light.
  76361. * @hidden Internal use only.
  76362. */
  76363. _shadowGenerator: Nullable<IShadowGenerator>;
  76364. /**
  76365. * @hidden Internal use only.
  76366. */
  76367. _excludedMeshesIds: string[];
  76368. /**
  76369. * @hidden Internal use only.
  76370. */
  76371. _includedOnlyMeshesIds: string[];
  76372. /**
  76373. * The current light unifom buffer.
  76374. * @hidden Internal use only.
  76375. */
  76376. _uniformBuffer: UniformBuffer;
  76377. /**
  76378. * Creates a Light object in the scene.
  76379. * Documentation : https://doc.babylonjs.com/babylon101/lights
  76380. * @param name The firendly name of the light
  76381. * @param scene The scene the light belongs too
  76382. */
  76383. constructor(name: string, scene: Scene);
  76384. protected abstract _buildUniformLayout(): void;
  76385. /**
  76386. * Sets the passed Effect "effect" with the Light information.
  76387. * @param effect The effect to update
  76388. * @param lightIndex The index of the light in the effect to update
  76389. * @returns The light
  76390. */
  76391. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  76392. /**
  76393. * Sets the passed Effect "effect" with the Light information.
  76394. * @param effect The effect to update
  76395. * @param lightDataUniformName The uniform used to store light data (position or direction)
  76396. * @returns The light
  76397. */
  76398. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  76399. /**
  76400. * Returns the string "Light".
  76401. * @returns the class name
  76402. */
  76403. getClassName(): string;
  76404. /** @hidden */
  76405. readonly _isLight: boolean;
  76406. /**
  76407. * Converts the light information to a readable string for debug purpose.
  76408. * @param fullDetails Supports for multiple levels of logging within scene loading
  76409. * @returns the human readable light info
  76410. */
  76411. toString(fullDetails?: boolean): string;
  76412. /** @hidden */
  76413. protected _syncParentEnabledState(): void;
  76414. /**
  76415. * Set the enabled state of this node.
  76416. * @param value - the new enabled state
  76417. */
  76418. setEnabled(value: boolean): void;
  76419. /**
  76420. * Returns the Light associated shadow generator if any.
  76421. * @return the associated shadow generator.
  76422. */
  76423. getShadowGenerator(): Nullable<IShadowGenerator>;
  76424. /**
  76425. * Returns a Vector3, the absolute light position in the World.
  76426. * @returns the world space position of the light
  76427. */
  76428. getAbsolutePosition(): Vector3;
  76429. /**
  76430. * Specifies if the light will affect the passed mesh.
  76431. * @param mesh The mesh to test against the light
  76432. * @return true the mesh is affected otherwise, false.
  76433. */
  76434. canAffectMesh(mesh: AbstractMesh): boolean;
  76435. /**
  76436. * Sort function to order lights for rendering.
  76437. * @param a First Light object to compare to second.
  76438. * @param b Second Light object to compare first.
  76439. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  76440. */
  76441. static CompareLightsPriority(a: Light, b: Light): number;
  76442. /**
  76443. * Releases resources associated with this node.
  76444. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  76445. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  76446. */
  76447. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76448. /**
  76449. * Returns the light type ID (integer).
  76450. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  76451. */
  76452. getTypeID(): number;
  76453. /**
  76454. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  76455. * @returns the scaled intensity in intensity mode unit
  76456. */
  76457. getScaledIntensity(): number;
  76458. /**
  76459. * Returns a new Light object, named "name", from the current one.
  76460. * @param name The name of the cloned light
  76461. * @returns the new created light
  76462. */
  76463. clone(name: string): Nullable<Light>;
  76464. /**
  76465. * Serializes the current light into a Serialization object.
  76466. * @returns the serialized object.
  76467. */
  76468. serialize(): any;
  76469. /**
  76470. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  76471. * This new light is named "name" and added to the passed scene.
  76472. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  76473. * @param name The friendly name of the light
  76474. * @param scene The scene the new light will belong to
  76475. * @returns the constructor function
  76476. */
  76477. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  76478. /**
  76479. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  76480. * @param parsedLight The JSON representation of the light
  76481. * @param scene The scene to create the parsed light in
  76482. * @returns the created light after parsing
  76483. */
  76484. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  76485. private _hookArrayForExcluded;
  76486. private _hookArrayForIncludedOnly;
  76487. private _resyncMeshes;
  76488. /**
  76489. * Forces the meshes to update their light related information in their rendering used effects
  76490. * @hidden Internal Use Only
  76491. */
  76492. _markMeshesAsLightDirty(): void;
  76493. /**
  76494. * Recomputes the cached photometric scale if needed.
  76495. */
  76496. private _computePhotometricScale;
  76497. /**
  76498. * Returns the Photometric Scale according to the light type and intensity mode.
  76499. */
  76500. private _getPhotometricScale;
  76501. /**
  76502. * Reorder the light in the scene according to their defined priority.
  76503. * @hidden Internal Use Only
  76504. */
  76505. _reorderLightsInScene(): void;
  76506. /**
  76507. * Prepares the list of defines specific to the light type.
  76508. * @param defines the list of defines
  76509. * @param lightIndex defines the index of the light for the effect
  76510. */
  76511. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  76512. }
  76513. }
  76514. declare module BABYLON {
  76515. /**
  76516. * Interface used to define Action
  76517. */
  76518. export interface IAction {
  76519. /**
  76520. * Trigger for the action
  76521. */
  76522. trigger: number;
  76523. /** Options of the trigger */
  76524. triggerOptions: any;
  76525. /**
  76526. * Gets the trigger parameters
  76527. * @returns the trigger parameters
  76528. */
  76529. getTriggerParameter(): any;
  76530. /**
  76531. * Internal only - executes current action event
  76532. * @hidden
  76533. */
  76534. _executeCurrent(evt?: ActionEvent): void;
  76535. /**
  76536. * Serialize placeholder for child classes
  76537. * @param parent of child
  76538. * @returns the serialized object
  76539. */
  76540. serialize(parent: any): any;
  76541. /**
  76542. * Internal only
  76543. * @hidden
  76544. */
  76545. _prepare(): void;
  76546. /**
  76547. * Internal only - manager for action
  76548. * @hidden
  76549. */
  76550. _actionManager: AbstractActionManager;
  76551. /**
  76552. * Adds action to chain of actions, may be a DoNothingAction
  76553. * @param action defines the next action to execute
  76554. * @returns The action passed in
  76555. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76556. */
  76557. then(action: IAction): IAction;
  76558. }
  76559. /**
  76560. * The action to be carried out following a trigger
  76561. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  76562. */
  76563. export class Action implements IAction {
  76564. /** the trigger, with or without parameters, for the action */
  76565. triggerOptions: any;
  76566. /**
  76567. * Trigger for the action
  76568. */
  76569. trigger: number;
  76570. /**
  76571. * Internal only - manager for action
  76572. * @hidden
  76573. */
  76574. _actionManager: ActionManager;
  76575. private _nextActiveAction;
  76576. private _child;
  76577. private _condition?;
  76578. private _triggerParameter;
  76579. /**
  76580. * An event triggered prior to action being executed.
  76581. */
  76582. onBeforeExecuteObservable: Observable<Action>;
  76583. /**
  76584. * Creates a new Action
  76585. * @param triggerOptions the trigger, with or without parameters, for the action
  76586. * @param condition an optional determinant of action
  76587. */
  76588. constructor(
  76589. /** the trigger, with or without parameters, for the action */
  76590. triggerOptions: any, condition?: Condition);
  76591. /**
  76592. * Internal only
  76593. * @hidden
  76594. */
  76595. _prepare(): void;
  76596. /**
  76597. * Gets the trigger parameters
  76598. * @returns the trigger parameters
  76599. */
  76600. getTriggerParameter(): any;
  76601. /**
  76602. * Internal only - executes current action event
  76603. * @hidden
  76604. */
  76605. _executeCurrent(evt?: ActionEvent): void;
  76606. /**
  76607. * Execute placeholder for child classes
  76608. * @param evt optional action event
  76609. */
  76610. execute(evt?: ActionEvent): void;
  76611. /**
  76612. * Skips to next active action
  76613. */
  76614. skipToNextActiveAction(): void;
  76615. /**
  76616. * Adds action to chain of actions, may be a DoNothingAction
  76617. * @param action defines the next action to execute
  76618. * @returns The action passed in
  76619. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76620. */
  76621. then(action: Action): Action;
  76622. /**
  76623. * Internal only
  76624. * @hidden
  76625. */
  76626. _getProperty(propertyPath: string): string;
  76627. /**
  76628. * Internal only
  76629. * @hidden
  76630. */
  76631. _getEffectiveTarget(target: any, propertyPath: string): any;
  76632. /**
  76633. * Serialize placeholder for child classes
  76634. * @param parent of child
  76635. * @returns the serialized object
  76636. */
  76637. serialize(parent: any): any;
  76638. /**
  76639. * Internal only called by serialize
  76640. * @hidden
  76641. */
  76642. protected _serialize(serializedAction: any, parent?: any): any;
  76643. /**
  76644. * Internal only
  76645. * @hidden
  76646. */
  76647. static _SerializeValueAsString: (value: any) => string;
  76648. /**
  76649. * Internal only
  76650. * @hidden
  76651. */
  76652. static _GetTargetProperty: (target: Node | Scene) => {
  76653. name: string;
  76654. targetType: string;
  76655. value: string;
  76656. };
  76657. }
  76658. }
  76659. declare module BABYLON {
  76660. /**
  76661. * A Condition applied to an Action
  76662. */
  76663. export class Condition {
  76664. /**
  76665. * Internal only - manager for action
  76666. * @hidden
  76667. */
  76668. _actionManager: ActionManager;
  76669. /**
  76670. * Internal only
  76671. * @hidden
  76672. */
  76673. _evaluationId: number;
  76674. /**
  76675. * Internal only
  76676. * @hidden
  76677. */
  76678. _currentResult: boolean;
  76679. /**
  76680. * Creates a new Condition
  76681. * @param actionManager the manager of the action the condition is applied to
  76682. */
  76683. constructor(actionManager: ActionManager);
  76684. /**
  76685. * Check if the current condition is valid
  76686. * @returns a boolean
  76687. */
  76688. isValid(): boolean;
  76689. /**
  76690. * Internal only
  76691. * @hidden
  76692. */
  76693. _getProperty(propertyPath: string): string;
  76694. /**
  76695. * Internal only
  76696. * @hidden
  76697. */
  76698. _getEffectiveTarget(target: any, propertyPath: string): any;
  76699. /**
  76700. * Serialize placeholder for child classes
  76701. * @returns the serialized object
  76702. */
  76703. serialize(): any;
  76704. /**
  76705. * Internal only
  76706. * @hidden
  76707. */
  76708. protected _serialize(serializedCondition: any): any;
  76709. }
  76710. /**
  76711. * Defines specific conditional operators as extensions of Condition
  76712. */
  76713. export class ValueCondition extends Condition {
  76714. /** path to specify the property of the target the conditional operator uses */
  76715. propertyPath: string;
  76716. /** the value compared by the conditional operator against the current value of the property */
  76717. value: any;
  76718. /** the conditional operator, default ValueCondition.IsEqual */
  76719. operator: number;
  76720. /**
  76721. * Internal only
  76722. * @hidden
  76723. */
  76724. private static _IsEqual;
  76725. /**
  76726. * Internal only
  76727. * @hidden
  76728. */
  76729. private static _IsDifferent;
  76730. /**
  76731. * Internal only
  76732. * @hidden
  76733. */
  76734. private static _IsGreater;
  76735. /**
  76736. * Internal only
  76737. * @hidden
  76738. */
  76739. private static _IsLesser;
  76740. /**
  76741. * returns the number for IsEqual
  76742. */
  76743. static readonly IsEqual: number;
  76744. /**
  76745. * Returns the number for IsDifferent
  76746. */
  76747. static readonly IsDifferent: number;
  76748. /**
  76749. * Returns the number for IsGreater
  76750. */
  76751. static readonly IsGreater: number;
  76752. /**
  76753. * Returns the number for IsLesser
  76754. */
  76755. static readonly IsLesser: number;
  76756. /**
  76757. * Internal only The action manager for the condition
  76758. * @hidden
  76759. */
  76760. _actionManager: ActionManager;
  76761. /**
  76762. * Internal only
  76763. * @hidden
  76764. */
  76765. private _target;
  76766. /**
  76767. * Internal only
  76768. * @hidden
  76769. */
  76770. private _effectiveTarget;
  76771. /**
  76772. * Internal only
  76773. * @hidden
  76774. */
  76775. private _property;
  76776. /**
  76777. * Creates a new ValueCondition
  76778. * @param actionManager manager for the action the condition applies to
  76779. * @param target for the action
  76780. * @param propertyPath path to specify the property of the target the conditional operator uses
  76781. * @param value the value compared by the conditional operator against the current value of the property
  76782. * @param operator the conditional operator, default ValueCondition.IsEqual
  76783. */
  76784. constructor(actionManager: ActionManager, target: any,
  76785. /** path to specify the property of the target the conditional operator uses */
  76786. propertyPath: string,
  76787. /** the value compared by the conditional operator against the current value of the property */
  76788. value: any,
  76789. /** the conditional operator, default ValueCondition.IsEqual */
  76790. operator?: number);
  76791. /**
  76792. * Compares the given value with the property value for the specified conditional operator
  76793. * @returns the result of the comparison
  76794. */
  76795. isValid(): boolean;
  76796. /**
  76797. * Serialize the ValueCondition into a JSON compatible object
  76798. * @returns serialization object
  76799. */
  76800. serialize(): any;
  76801. /**
  76802. * Gets the name of the conditional operator for the ValueCondition
  76803. * @param operator the conditional operator
  76804. * @returns the name
  76805. */
  76806. static GetOperatorName(operator: number): string;
  76807. }
  76808. /**
  76809. * Defines a predicate condition as an extension of Condition
  76810. */
  76811. export class PredicateCondition extends Condition {
  76812. /** defines the predicate function used to validate the condition */
  76813. predicate: () => boolean;
  76814. /**
  76815. * Internal only - manager for action
  76816. * @hidden
  76817. */
  76818. _actionManager: ActionManager;
  76819. /**
  76820. * Creates a new PredicateCondition
  76821. * @param actionManager manager for the action the condition applies to
  76822. * @param predicate defines the predicate function used to validate the condition
  76823. */
  76824. constructor(actionManager: ActionManager,
  76825. /** defines the predicate function used to validate the condition */
  76826. predicate: () => boolean);
  76827. /**
  76828. * @returns the validity of the predicate condition
  76829. */
  76830. isValid(): boolean;
  76831. }
  76832. /**
  76833. * Defines a state condition as an extension of Condition
  76834. */
  76835. export class StateCondition extends Condition {
  76836. /** Value to compare with target state */
  76837. value: string;
  76838. /**
  76839. * Internal only - manager for action
  76840. * @hidden
  76841. */
  76842. _actionManager: ActionManager;
  76843. /**
  76844. * Internal only
  76845. * @hidden
  76846. */
  76847. private _target;
  76848. /**
  76849. * Creates a new StateCondition
  76850. * @param actionManager manager for the action the condition applies to
  76851. * @param target of the condition
  76852. * @param value to compare with target state
  76853. */
  76854. constructor(actionManager: ActionManager, target: any,
  76855. /** Value to compare with target state */
  76856. value: string);
  76857. /**
  76858. * Gets a boolean indicating if the current condition is met
  76859. * @returns the validity of the state
  76860. */
  76861. isValid(): boolean;
  76862. /**
  76863. * Serialize the StateCondition into a JSON compatible object
  76864. * @returns serialization object
  76865. */
  76866. serialize(): any;
  76867. }
  76868. }
  76869. declare module BABYLON {
  76870. /**
  76871. * This defines an action responsible to toggle a boolean once triggered.
  76872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76873. */
  76874. export class SwitchBooleanAction extends Action {
  76875. /**
  76876. * The path to the boolean property in the target object
  76877. */
  76878. propertyPath: string;
  76879. private _target;
  76880. private _effectiveTarget;
  76881. private _property;
  76882. /**
  76883. * Instantiate the action
  76884. * @param triggerOptions defines the trigger options
  76885. * @param target defines the object containing the boolean
  76886. * @param propertyPath defines the path to the boolean property in the target object
  76887. * @param condition defines the trigger related conditions
  76888. */
  76889. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  76890. /** @hidden */
  76891. _prepare(): void;
  76892. /**
  76893. * Execute the action toggle the boolean value.
  76894. */
  76895. execute(): void;
  76896. /**
  76897. * Serializes the actions and its related information.
  76898. * @param parent defines the object to serialize in
  76899. * @returns the serialized object
  76900. */
  76901. serialize(parent: any): any;
  76902. }
  76903. /**
  76904. * This defines an action responsible to set a the state field of the target
  76905. * to a desired value once triggered.
  76906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76907. */
  76908. export class SetStateAction extends Action {
  76909. /**
  76910. * The value to store in the state field.
  76911. */
  76912. value: string;
  76913. private _target;
  76914. /**
  76915. * Instantiate the action
  76916. * @param triggerOptions defines the trigger options
  76917. * @param target defines the object containing the state property
  76918. * @param value defines the value to store in the state field
  76919. * @param condition defines the trigger related conditions
  76920. */
  76921. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  76922. /**
  76923. * Execute the action and store the value on the target state property.
  76924. */
  76925. execute(): void;
  76926. /**
  76927. * Serializes the actions and its related information.
  76928. * @param parent defines the object to serialize in
  76929. * @returns the serialized object
  76930. */
  76931. serialize(parent: any): any;
  76932. }
  76933. /**
  76934. * This defines an action responsible to set a property of the target
  76935. * to a desired value once triggered.
  76936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76937. */
  76938. export class SetValueAction extends Action {
  76939. /**
  76940. * The path of the property to set in the target.
  76941. */
  76942. propertyPath: string;
  76943. /**
  76944. * The value to set in the property
  76945. */
  76946. value: any;
  76947. private _target;
  76948. private _effectiveTarget;
  76949. private _property;
  76950. /**
  76951. * Instantiate the action
  76952. * @param triggerOptions defines the trigger options
  76953. * @param target defines the object containing the property
  76954. * @param propertyPath defines the path of the property to set in the target
  76955. * @param value defines the value to set in the property
  76956. * @param condition defines the trigger related conditions
  76957. */
  76958. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76959. /** @hidden */
  76960. _prepare(): void;
  76961. /**
  76962. * Execute the action and set the targetted property to the desired value.
  76963. */
  76964. execute(): void;
  76965. /**
  76966. * Serializes the actions and its related information.
  76967. * @param parent defines the object to serialize in
  76968. * @returns the serialized object
  76969. */
  76970. serialize(parent: any): any;
  76971. }
  76972. /**
  76973. * This defines an action responsible to increment the target value
  76974. * to a desired value once triggered.
  76975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76976. */
  76977. export class IncrementValueAction extends Action {
  76978. /**
  76979. * The path of the property to increment in the target.
  76980. */
  76981. propertyPath: string;
  76982. /**
  76983. * The value we should increment the property by.
  76984. */
  76985. value: any;
  76986. private _target;
  76987. private _effectiveTarget;
  76988. private _property;
  76989. /**
  76990. * Instantiate the action
  76991. * @param triggerOptions defines the trigger options
  76992. * @param target defines the object containing the property
  76993. * @param propertyPath defines the path of the property to increment in the target
  76994. * @param value defines the value value we should increment the property by
  76995. * @param condition defines the trigger related conditions
  76996. */
  76997. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76998. /** @hidden */
  76999. _prepare(): void;
  77000. /**
  77001. * Execute the action and increment the target of the value amount.
  77002. */
  77003. execute(): void;
  77004. /**
  77005. * Serializes the actions and its related information.
  77006. * @param parent defines the object to serialize in
  77007. * @returns the serialized object
  77008. */
  77009. serialize(parent: any): any;
  77010. }
  77011. /**
  77012. * This defines an action responsible to start an animation once triggered.
  77013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77014. */
  77015. export class PlayAnimationAction extends Action {
  77016. /**
  77017. * Where the animation should start (animation frame)
  77018. */
  77019. from: number;
  77020. /**
  77021. * Where the animation should stop (animation frame)
  77022. */
  77023. to: number;
  77024. /**
  77025. * Define if the animation should loop or stop after the first play.
  77026. */
  77027. loop?: boolean;
  77028. private _target;
  77029. /**
  77030. * Instantiate the action
  77031. * @param triggerOptions defines the trigger options
  77032. * @param target defines the target animation or animation name
  77033. * @param from defines from where the animation should start (animation frame)
  77034. * @param end defines where the animation should stop (animation frame)
  77035. * @param loop defines if the animation should loop or stop after the first play
  77036. * @param condition defines the trigger related conditions
  77037. */
  77038. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  77039. /** @hidden */
  77040. _prepare(): void;
  77041. /**
  77042. * Execute the action and play the animation.
  77043. */
  77044. execute(): void;
  77045. /**
  77046. * Serializes the actions and its related information.
  77047. * @param parent defines the object to serialize in
  77048. * @returns the serialized object
  77049. */
  77050. serialize(parent: any): any;
  77051. }
  77052. /**
  77053. * This defines an action responsible to stop an animation once triggered.
  77054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77055. */
  77056. export class StopAnimationAction extends Action {
  77057. private _target;
  77058. /**
  77059. * Instantiate the action
  77060. * @param triggerOptions defines the trigger options
  77061. * @param target defines the target animation or animation name
  77062. * @param condition defines the trigger related conditions
  77063. */
  77064. constructor(triggerOptions: any, target: any, condition?: Condition);
  77065. /** @hidden */
  77066. _prepare(): void;
  77067. /**
  77068. * Execute the action and stop the animation.
  77069. */
  77070. execute(): void;
  77071. /**
  77072. * Serializes the actions and its related information.
  77073. * @param parent defines the object to serialize in
  77074. * @returns the serialized object
  77075. */
  77076. serialize(parent: any): any;
  77077. }
  77078. /**
  77079. * This defines an action responsible that does nothing once triggered.
  77080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77081. */
  77082. export class DoNothingAction extends Action {
  77083. /**
  77084. * Instantiate the action
  77085. * @param triggerOptions defines the trigger options
  77086. * @param condition defines the trigger related conditions
  77087. */
  77088. constructor(triggerOptions?: any, condition?: Condition);
  77089. /**
  77090. * Execute the action and do nothing.
  77091. */
  77092. execute(): void;
  77093. /**
  77094. * Serializes the actions and its related information.
  77095. * @param parent defines the object to serialize in
  77096. * @returns the serialized object
  77097. */
  77098. serialize(parent: any): any;
  77099. }
  77100. /**
  77101. * This defines an action responsible to trigger several actions once triggered.
  77102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77103. */
  77104. export class CombineAction extends Action {
  77105. /**
  77106. * The list of aggregated animations to run.
  77107. */
  77108. children: Action[];
  77109. /**
  77110. * Instantiate the action
  77111. * @param triggerOptions defines the trigger options
  77112. * @param children defines the list of aggregated animations to run
  77113. * @param condition defines the trigger related conditions
  77114. */
  77115. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  77116. /** @hidden */
  77117. _prepare(): void;
  77118. /**
  77119. * Execute the action and executes all the aggregated actions.
  77120. */
  77121. execute(evt: ActionEvent): void;
  77122. /**
  77123. * Serializes the actions and its related information.
  77124. * @param parent defines the object to serialize in
  77125. * @returns the serialized object
  77126. */
  77127. serialize(parent: any): any;
  77128. }
  77129. /**
  77130. * This defines an action responsible to run code (external event) once triggered.
  77131. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77132. */
  77133. export class ExecuteCodeAction extends Action {
  77134. /**
  77135. * The callback function to run.
  77136. */
  77137. func: (evt: ActionEvent) => void;
  77138. /**
  77139. * Instantiate the action
  77140. * @param triggerOptions defines the trigger options
  77141. * @param func defines the callback function to run
  77142. * @param condition defines the trigger related conditions
  77143. */
  77144. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  77145. /**
  77146. * Execute the action and run the attached code.
  77147. */
  77148. execute(evt: ActionEvent): void;
  77149. }
  77150. /**
  77151. * This defines an action responsible to set the parent property of the target once triggered.
  77152. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77153. */
  77154. export class SetParentAction extends Action {
  77155. private _parent;
  77156. private _target;
  77157. /**
  77158. * Instantiate the action
  77159. * @param triggerOptions defines the trigger options
  77160. * @param target defines the target containing the parent property
  77161. * @param parent defines from where the animation should start (animation frame)
  77162. * @param condition defines the trigger related conditions
  77163. */
  77164. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  77165. /** @hidden */
  77166. _prepare(): void;
  77167. /**
  77168. * Execute the action and set the parent property.
  77169. */
  77170. execute(): void;
  77171. /**
  77172. * Serializes the actions and its related information.
  77173. * @param parent defines the object to serialize in
  77174. * @returns the serialized object
  77175. */
  77176. serialize(parent: any): any;
  77177. }
  77178. }
  77179. declare module BABYLON {
  77180. /**
  77181. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  77182. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  77183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77184. */
  77185. export class ActionManager extends AbstractActionManager {
  77186. /**
  77187. * Nothing
  77188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77189. */
  77190. static readonly NothingTrigger: number;
  77191. /**
  77192. * On pick
  77193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77194. */
  77195. static readonly OnPickTrigger: number;
  77196. /**
  77197. * On left pick
  77198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77199. */
  77200. static readonly OnLeftPickTrigger: number;
  77201. /**
  77202. * On right pick
  77203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77204. */
  77205. static readonly OnRightPickTrigger: number;
  77206. /**
  77207. * On center pick
  77208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77209. */
  77210. static readonly OnCenterPickTrigger: number;
  77211. /**
  77212. * On pick down
  77213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77214. */
  77215. static readonly OnPickDownTrigger: number;
  77216. /**
  77217. * On double pick
  77218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77219. */
  77220. static readonly OnDoublePickTrigger: number;
  77221. /**
  77222. * On pick up
  77223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77224. */
  77225. static readonly OnPickUpTrigger: number;
  77226. /**
  77227. * On pick out.
  77228. * This trigger will only be raised if you also declared a OnPickDown
  77229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77230. */
  77231. static readonly OnPickOutTrigger: number;
  77232. /**
  77233. * On long press
  77234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77235. */
  77236. static readonly OnLongPressTrigger: number;
  77237. /**
  77238. * On pointer over
  77239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77240. */
  77241. static readonly OnPointerOverTrigger: number;
  77242. /**
  77243. * On pointer out
  77244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77245. */
  77246. static readonly OnPointerOutTrigger: number;
  77247. /**
  77248. * On every frame
  77249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77250. */
  77251. static readonly OnEveryFrameTrigger: number;
  77252. /**
  77253. * On intersection enter
  77254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77255. */
  77256. static readonly OnIntersectionEnterTrigger: number;
  77257. /**
  77258. * On intersection exit
  77259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77260. */
  77261. static readonly OnIntersectionExitTrigger: number;
  77262. /**
  77263. * On key down
  77264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77265. */
  77266. static readonly OnKeyDownTrigger: number;
  77267. /**
  77268. * On key up
  77269. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77270. */
  77271. static readonly OnKeyUpTrigger: number;
  77272. private _scene;
  77273. /**
  77274. * Creates a new action manager
  77275. * @param scene defines the hosting scene
  77276. */
  77277. constructor(scene: Scene);
  77278. /**
  77279. * Releases all associated resources
  77280. */
  77281. dispose(): void;
  77282. /**
  77283. * Gets hosting scene
  77284. * @returns the hosting scene
  77285. */
  77286. getScene(): Scene;
  77287. /**
  77288. * Does this action manager handles actions of any of the given triggers
  77289. * @param triggers defines the triggers to be tested
  77290. * @return a boolean indicating whether one (or more) of the triggers is handled
  77291. */
  77292. hasSpecificTriggers(triggers: number[]): boolean;
  77293. /**
  77294. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  77295. * speed.
  77296. * @param triggerA defines the trigger to be tested
  77297. * @param triggerB defines the trigger to be tested
  77298. * @return a boolean indicating whether one (or more) of the triggers is handled
  77299. */
  77300. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  77301. /**
  77302. * Does this action manager handles actions of a given trigger
  77303. * @param trigger defines the trigger to be tested
  77304. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  77305. * @return whether the trigger is handled
  77306. */
  77307. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  77308. /**
  77309. * Does this action manager has pointer triggers
  77310. */
  77311. readonly hasPointerTriggers: boolean;
  77312. /**
  77313. * Does this action manager has pick triggers
  77314. */
  77315. readonly hasPickTriggers: boolean;
  77316. /**
  77317. * Registers an action to this action manager
  77318. * @param action defines the action to be registered
  77319. * @return the action amended (prepared) after registration
  77320. */
  77321. registerAction(action: IAction): Nullable<IAction>;
  77322. /**
  77323. * Unregisters an action to this action manager
  77324. * @param action defines the action to be unregistered
  77325. * @return a boolean indicating whether the action has been unregistered
  77326. */
  77327. unregisterAction(action: IAction): Boolean;
  77328. /**
  77329. * Process a specific trigger
  77330. * @param trigger defines the trigger to process
  77331. * @param evt defines the event details to be processed
  77332. */
  77333. processTrigger(trigger: number, evt?: IActionEvent): void;
  77334. /** @hidden */
  77335. _getEffectiveTarget(target: any, propertyPath: string): any;
  77336. /** @hidden */
  77337. _getProperty(propertyPath: string): string;
  77338. /**
  77339. * Serialize this manager to a JSON object
  77340. * @param name defines the property name to store this manager
  77341. * @returns a JSON representation of this manager
  77342. */
  77343. serialize(name: string): any;
  77344. /**
  77345. * Creates a new ActionManager from a JSON data
  77346. * @param parsedActions defines the JSON data to read from
  77347. * @param object defines the hosting mesh
  77348. * @param scene defines the hosting scene
  77349. */
  77350. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  77351. /**
  77352. * Get a trigger name by index
  77353. * @param trigger defines the trigger index
  77354. * @returns a trigger name
  77355. */
  77356. static GetTriggerName(trigger: number): string;
  77357. }
  77358. }
  77359. declare module BABYLON {
  77360. /**
  77361. * Class representing a ray with position and direction
  77362. */
  77363. export class Ray {
  77364. /** origin point */
  77365. origin: Vector3;
  77366. /** direction */
  77367. direction: Vector3;
  77368. /** length of the ray */
  77369. length: number;
  77370. private static readonly TmpVector3;
  77371. private _tmpRay;
  77372. /**
  77373. * Creates a new ray
  77374. * @param origin origin point
  77375. * @param direction direction
  77376. * @param length length of the ray
  77377. */
  77378. constructor(
  77379. /** origin point */
  77380. origin: Vector3,
  77381. /** direction */
  77382. direction: Vector3,
  77383. /** length of the ray */
  77384. length?: number);
  77385. /**
  77386. * Checks if the ray intersects a box
  77387. * @param minimum bound of the box
  77388. * @param maximum bound of the box
  77389. * @param intersectionTreshold extra extend to be added to the box in all direction
  77390. * @returns if the box was hit
  77391. */
  77392. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  77393. /**
  77394. * Checks if the ray intersects a box
  77395. * @param box the bounding box to check
  77396. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  77397. * @returns if the box was hit
  77398. */
  77399. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  77400. /**
  77401. * If the ray hits a sphere
  77402. * @param sphere the bounding sphere to check
  77403. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  77404. * @returns true if it hits the sphere
  77405. */
  77406. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  77407. /**
  77408. * If the ray hits a triange
  77409. * @param vertex0 triangle vertex
  77410. * @param vertex1 triangle vertex
  77411. * @param vertex2 triangle vertex
  77412. * @returns intersection information if hit
  77413. */
  77414. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  77415. /**
  77416. * Checks if ray intersects a plane
  77417. * @param plane the plane to check
  77418. * @returns the distance away it was hit
  77419. */
  77420. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  77421. /**
  77422. * Calculate the intercept of a ray on a given axis
  77423. * @param axis to check 'x' | 'y' | 'z'
  77424. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  77425. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  77426. */
  77427. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  77428. /**
  77429. * Checks if ray intersects a mesh
  77430. * @param mesh the mesh to check
  77431. * @param fastCheck if only the bounding box should checked
  77432. * @returns picking info of the intersecton
  77433. */
  77434. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  77435. /**
  77436. * Checks if ray intersects a mesh
  77437. * @param meshes the meshes to check
  77438. * @param fastCheck if only the bounding box should checked
  77439. * @param results array to store result in
  77440. * @returns Array of picking infos
  77441. */
  77442. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  77443. private _comparePickingInfo;
  77444. private static smallnum;
  77445. private static rayl;
  77446. /**
  77447. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  77448. * @param sega the first point of the segment to test the intersection against
  77449. * @param segb the second point of the segment to test the intersection against
  77450. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  77451. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  77452. */
  77453. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  77454. /**
  77455. * Update the ray from viewport position
  77456. * @param x position
  77457. * @param y y position
  77458. * @param viewportWidth viewport width
  77459. * @param viewportHeight viewport height
  77460. * @param world world matrix
  77461. * @param view view matrix
  77462. * @param projection projection matrix
  77463. * @returns this ray updated
  77464. */
  77465. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77466. /**
  77467. * Creates a ray with origin and direction of 0,0,0
  77468. * @returns the new ray
  77469. */
  77470. static Zero(): Ray;
  77471. /**
  77472. * Creates a new ray from screen space and viewport
  77473. * @param x position
  77474. * @param y y position
  77475. * @param viewportWidth viewport width
  77476. * @param viewportHeight viewport height
  77477. * @param world world matrix
  77478. * @param view view matrix
  77479. * @param projection projection matrix
  77480. * @returns new ray
  77481. */
  77482. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77483. /**
  77484. * 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
  77485. * transformed to the given world matrix.
  77486. * @param origin The origin point
  77487. * @param end The end point
  77488. * @param world a matrix to transform the ray to. Default is the identity matrix.
  77489. * @returns the new ray
  77490. */
  77491. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  77492. /**
  77493. * Transforms a ray by a matrix
  77494. * @param ray ray to transform
  77495. * @param matrix matrix to apply
  77496. * @returns the resulting new ray
  77497. */
  77498. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  77499. /**
  77500. * Transforms a ray by a matrix
  77501. * @param ray ray to transform
  77502. * @param matrix matrix to apply
  77503. * @param result ray to store result in
  77504. */
  77505. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  77506. /**
  77507. * Unproject a ray from screen space to object space
  77508. * @param sourceX defines the screen space x coordinate to use
  77509. * @param sourceY defines the screen space y coordinate to use
  77510. * @param viewportWidth defines the current width of the viewport
  77511. * @param viewportHeight defines the current height of the viewport
  77512. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77513. * @param view defines the view matrix to use
  77514. * @param projection defines the projection matrix to use
  77515. */
  77516. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  77517. }
  77518. /**
  77519. * Type used to define predicate used to select faces when a mesh intersection is detected
  77520. */
  77521. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  77522. interface Scene {
  77523. /** @hidden */
  77524. _tempPickingRay: Nullable<Ray>;
  77525. /** @hidden */
  77526. _cachedRayForTransform: Ray;
  77527. /** @hidden */
  77528. _pickWithRayInverseMatrix: Matrix;
  77529. /** @hidden */
  77530. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  77531. /** @hidden */
  77532. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  77533. }
  77534. }
  77535. declare module BABYLON {
  77536. /**
  77537. * Groups all the scene component constants in one place to ease maintenance.
  77538. * @hidden
  77539. */
  77540. export class SceneComponentConstants {
  77541. static readonly NAME_EFFECTLAYER: string;
  77542. static readonly NAME_LAYER: string;
  77543. static readonly NAME_LENSFLARESYSTEM: string;
  77544. static readonly NAME_BOUNDINGBOXRENDERER: string;
  77545. static readonly NAME_PARTICLESYSTEM: string;
  77546. static readonly NAME_GAMEPAD: string;
  77547. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  77548. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  77549. static readonly NAME_DEPTHRENDERER: string;
  77550. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  77551. static readonly NAME_SPRITE: string;
  77552. static readonly NAME_OUTLINERENDERER: string;
  77553. static readonly NAME_PROCEDURALTEXTURE: string;
  77554. static readonly NAME_SHADOWGENERATOR: string;
  77555. static readonly NAME_OCTREE: string;
  77556. static readonly NAME_PHYSICSENGINE: string;
  77557. static readonly NAME_AUDIO: string;
  77558. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  77559. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77560. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  77561. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77562. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  77563. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  77564. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  77565. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  77566. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  77567. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  77568. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  77569. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  77570. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  77571. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  77572. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  77573. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  77574. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  77575. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  77576. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  77577. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  77578. static readonly STEP_AFTERRENDER_AUDIO: number;
  77579. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  77580. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  77581. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  77582. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  77583. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  77584. static readonly STEP_POINTERMOVE_SPRITE: number;
  77585. static readonly STEP_POINTERDOWN_SPRITE: number;
  77586. static readonly STEP_POINTERUP_SPRITE: number;
  77587. }
  77588. /**
  77589. * This represents a scene component.
  77590. *
  77591. * This is used to decouple the dependency the scene is having on the different workloads like
  77592. * layers, post processes...
  77593. */
  77594. export interface ISceneComponent {
  77595. /**
  77596. * The name of the component. Each component must have a unique name.
  77597. */
  77598. name: string;
  77599. /**
  77600. * The scene the component belongs to.
  77601. */
  77602. scene: Scene;
  77603. /**
  77604. * Register the component to one instance of a scene.
  77605. */
  77606. register(): void;
  77607. /**
  77608. * Rebuilds the elements related to this component in case of
  77609. * context lost for instance.
  77610. */
  77611. rebuild(): void;
  77612. /**
  77613. * Disposes the component and the associated ressources.
  77614. */
  77615. dispose(): void;
  77616. }
  77617. /**
  77618. * This represents a SERIALIZABLE scene component.
  77619. *
  77620. * This extends Scene Component to add Serialization methods on top.
  77621. */
  77622. export interface ISceneSerializableComponent extends ISceneComponent {
  77623. /**
  77624. * Adds all the elements from the container to the scene
  77625. * @param container the container holding the elements
  77626. */
  77627. addFromContainer(container: AbstractScene): void;
  77628. /**
  77629. * Removes all the elements in the container from the scene
  77630. * @param container contains the elements to remove
  77631. * @param dispose if the removed element should be disposed (default: false)
  77632. */
  77633. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77634. /**
  77635. * Serializes the component data to the specified json object
  77636. * @param serializationObject The object to serialize to
  77637. */
  77638. serialize(serializationObject: any): void;
  77639. }
  77640. /**
  77641. * Strong typing of a Mesh related stage step action
  77642. */
  77643. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  77644. /**
  77645. * Strong typing of a Evaluate Sub Mesh related stage step action
  77646. */
  77647. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  77648. /**
  77649. * Strong typing of a Active Mesh related stage step action
  77650. */
  77651. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  77652. /**
  77653. * Strong typing of a Camera related stage step action
  77654. */
  77655. export type CameraStageAction = (camera: Camera) => void;
  77656. /**
  77657. * Strong typing of a Camera Frame buffer related stage step action
  77658. */
  77659. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  77660. /**
  77661. * Strong typing of a Render Target related stage step action
  77662. */
  77663. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  77664. /**
  77665. * Strong typing of a RenderingGroup related stage step action
  77666. */
  77667. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  77668. /**
  77669. * Strong typing of a Mesh Render related stage step action
  77670. */
  77671. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  77672. /**
  77673. * Strong typing of a simple stage step action
  77674. */
  77675. export type SimpleStageAction = () => void;
  77676. /**
  77677. * Strong typing of a render target action.
  77678. */
  77679. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  77680. /**
  77681. * Strong typing of a pointer move action.
  77682. */
  77683. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  77684. /**
  77685. * Strong typing of a pointer up/down action.
  77686. */
  77687. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  77688. /**
  77689. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  77690. * @hidden
  77691. */
  77692. export class Stage<T extends Function> extends Array<{
  77693. index: number;
  77694. component: ISceneComponent;
  77695. action: T;
  77696. }> {
  77697. /**
  77698. * Hide ctor from the rest of the world.
  77699. * @param items The items to add.
  77700. */
  77701. private constructor();
  77702. /**
  77703. * Creates a new Stage.
  77704. * @returns A new instance of a Stage
  77705. */
  77706. static Create<T extends Function>(): Stage<T>;
  77707. /**
  77708. * Registers a step in an ordered way in the targeted stage.
  77709. * @param index Defines the position to register the step in
  77710. * @param component Defines the component attached to the step
  77711. * @param action Defines the action to launch during the step
  77712. */
  77713. registerStep(index: number, component: ISceneComponent, action: T): void;
  77714. /**
  77715. * Clears all the steps from the stage.
  77716. */
  77717. clear(): void;
  77718. }
  77719. }
  77720. declare module BABYLON {
  77721. interface Scene {
  77722. /** @hidden */
  77723. _pointerOverSprite: Nullable<Sprite>;
  77724. /** @hidden */
  77725. _pickedDownSprite: Nullable<Sprite>;
  77726. /** @hidden */
  77727. _tempSpritePickingRay: Nullable<Ray>;
  77728. /**
  77729. * All of the sprite managers added to this scene
  77730. * @see http://doc.babylonjs.com/babylon101/sprites
  77731. */
  77732. spriteManagers: Array<ISpriteManager>;
  77733. /**
  77734. * An event triggered when sprites rendering is about to start
  77735. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77736. */
  77737. onBeforeSpritesRenderingObservable: Observable<Scene>;
  77738. /**
  77739. * An event triggered when sprites rendering is done
  77740. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77741. */
  77742. onAfterSpritesRenderingObservable: Observable<Scene>;
  77743. /** @hidden */
  77744. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77745. /** Launch a ray to try to pick a sprite in the scene
  77746. * @param x position on screen
  77747. * @param y position on screen
  77748. * @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
  77749. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77750. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77751. * @returns a PickingInfo
  77752. */
  77753. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77754. /** Use the given ray to pick a sprite in the scene
  77755. * @param ray The ray (in world space) to use to pick meshes
  77756. * @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
  77757. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77758. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77759. * @returns a PickingInfo
  77760. */
  77761. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77762. /** @hidden */
  77763. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77764. /** Launch a ray to try to pick sprites in the scene
  77765. * @param x position on screen
  77766. * @param y position on screen
  77767. * @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
  77768. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77769. * @returns a PickingInfo array
  77770. */
  77771. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77772. /** Use the given ray to pick sprites in the scene
  77773. * @param ray The ray (in world space) to use to pick meshes
  77774. * @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
  77775. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77776. * @returns a PickingInfo array
  77777. */
  77778. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77779. /**
  77780. * Force the sprite under the pointer
  77781. * @param sprite defines the sprite to use
  77782. */
  77783. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  77784. /**
  77785. * Gets the sprite under the pointer
  77786. * @returns a Sprite or null if no sprite is under the pointer
  77787. */
  77788. getPointerOverSprite(): Nullable<Sprite>;
  77789. }
  77790. /**
  77791. * Defines the sprite scene component responsible to manage sprites
  77792. * in a given scene.
  77793. */
  77794. export class SpriteSceneComponent implements ISceneComponent {
  77795. /**
  77796. * The component name helpfull to identify the component in the list of scene components.
  77797. */
  77798. readonly name: string;
  77799. /**
  77800. * The scene the component belongs to.
  77801. */
  77802. scene: Scene;
  77803. /** @hidden */
  77804. private _spritePredicate;
  77805. /**
  77806. * Creates a new instance of the component for the given scene
  77807. * @param scene Defines the scene to register the component in
  77808. */
  77809. constructor(scene: Scene);
  77810. /**
  77811. * Registers the component in a given scene
  77812. */
  77813. register(): void;
  77814. /**
  77815. * Rebuilds the elements related to this component in case of
  77816. * context lost for instance.
  77817. */
  77818. rebuild(): void;
  77819. /**
  77820. * Disposes the component and the associated ressources.
  77821. */
  77822. dispose(): void;
  77823. private _pickSpriteButKeepRay;
  77824. private _pointerMove;
  77825. private _pointerDown;
  77826. private _pointerUp;
  77827. }
  77828. }
  77829. declare module BABYLON {
  77830. /** @hidden */
  77831. export var fogFragmentDeclaration: {
  77832. name: string;
  77833. shader: string;
  77834. };
  77835. }
  77836. declare module BABYLON {
  77837. /** @hidden */
  77838. export var fogFragment: {
  77839. name: string;
  77840. shader: string;
  77841. };
  77842. }
  77843. declare module BABYLON {
  77844. /** @hidden */
  77845. export var spritesPixelShader: {
  77846. name: string;
  77847. shader: string;
  77848. };
  77849. }
  77850. declare module BABYLON {
  77851. /** @hidden */
  77852. export var fogVertexDeclaration: {
  77853. name: string;
  77854. shader: string;
  77855. };
  77856. }
  77857. declare module BABYLON {
  77858. /** @hidden */
  77859. export var spritesVertexShader: {
  77860. name: string;
  77861. shader: string;
  77862. };
  77863. }
  77864. declare module BABYLON {
  77865. /**
  77866. * Defines the minimum interface to fullfil in order to be a sprite manager.
  77867. */
  77868. export interface ISpriteManager extends IDisposable {
  77869. /**
  77870. * Restricts the camera to viewing objects with the same layerMask.
  77871. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  77872. */
  77873. layerMask: number;
  77874. /**
  77875. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  77876. */
  77877. isPickable: boolean;
  77878. /**
  77879. * Specifies the rendering group id for this mesh (0 by default)
  77880. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  77881. */
  77882. renderingGroupId: number;
  77883. /**
  77884. * Defines the list of sprites managed by the manager.
  77885. */
  77886. sprites: Array<Sprite>;
  77887. /**
  77888. * Tests the intersection of a sprite with a specific ray.
  77889. * @param ray The ray we are sending to test the collision
  77890. * @param camera The camera space we are sending rays in
  77891. * @param predicate A predicate allowing excluding sprites from the list of object to test
  77892. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  77893. * @returns picking info or null.
  77894. */
  77895. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77896. /**
  77897. * Intersects the sprites with a ray
  77898. * @param ray defines the ray to intersect with
  77899. * @param camera defines the current active camera
  77900. * @param predicate defines a predicate used to select candidate sprites
  77901. * @returns null if no hit or a PickingInfo array
  77902. */
  77903. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77904. /**
  77905. * Renders the list of sprites on screen.
  77906. */
  77907. render(): void;
  77908. }
  77909. /**
  77910. * Class used to manage multiple sprites on the same spritesheet
  77911. * @see http://doc.babylonjs.com/babylon101/sprites
  77912. */
  77913. export class SpriteManager implements ISpriteManager {
  77914. /** defines the manager's name */
  77915. name: string;
  77916. /** Gets the list of sprites */
  77917. sprites: Sprite[];
  77918. /** Gets or sets the rendering group id (0 by default) */
  77919. renderingGroupId: number;
  77920. /** Gets or sets camera layer mask */
  77921. layerMask: number;
  77922. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  77923. fogEnabled: boolean;
  77924. /** Gets or sets a boolean indicating if the sprites are pickable */
  77925. isPickable: boolean;
  77926. /** Defines the default width of a cell in the spritesheet */
  77927. cellWidth: number;
  77928. /** Defines the default height of a cell in the spritesheet */
  77929. cellHeight: number;
  77930. /** Associative array from JSON sprite data file */
  77931. private _cellData;
  77932. /** Array of sprite names from JSON sprite data file */
  77933. private _spriteMap;
  77934. /** True when packed cell data from JSON file is ready*/
  77935. private _packedAndReady;
  77936. /**
  77937. * An event triggered when the manager is disposed.
  77938. */
  77939. onDisposeObservable: Observable<SpriteManager>;
  77940. private _onDisposeObserver;
  77941. /**
  77942. * Callback called when the manager is disposed
  77943. */
  77944. onDispose: () => void;
  77945. private _capacity;
  77946. private _fromPacked;
  77947. private _spriteTexture;
  77948. private _epsilon;
  77949. private _scene;
  77950. private _vertexData;
  77951. private _buffer;
  77952. private _vertexBuffers;
  77953. private _indexBuffer;
  77954. private _effectBase;
  77955. private _effectFog;
  77956. /**
  77957. * Gets or sets the spritesheet texture
  77958. */
  77959. texture: Texture;
  77960. /**
  77961. * Creates a new sprite manager
  77962. * @param name defines the manager's name
  77963. * @param imgUrl defines the sprite sheet url
  77964. * @param capacity defines the maximum allowed number of sprites
  77965. * @param cellSize defines the size of a sprite cell
  77966. * @param scene defines the hosting scene
  77967. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77968. * @param samplingMode defines the smapling mode to use with spritesheet
  77969. * @param fromPacked set to false; do not alter
  77970. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  77971. */
  77972. constructor(
  77973. /** defines the manager's name */
  77974. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  77975. private _makePacked;
  77976. private _appendSpriteVertex;
  77977. /**
  77978. * Intersects the sprites with a ray
  77979. * @param ray defines the ray to intersect with
  77980. * @param camera defines the current active camera
  77981. * @param predicate defines a predicate used to select candidate sprites
  77982. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  77983. * @returns null if no hit or a PickingInfo
  77984. */
  77985. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77986. /**
  77987. * Intersects the sprites with a ray
  77988. * @param ray defines the ray to intersect with
  77989. * @param camera defines the current active camera
  77990. * @param predicate defines a predicate used to select candidate sprites
  77991. * @returns null if no hit or a PickingInfo array
  77992. */
  77993. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77994. /**
  77995. * Render all child sprites
  77996. */
  77997. render(): void;
  77998. /**
  77999. * Release associated resources
  78000. */
  78001. dispose(): void;
  78002. }
  78003. }
  78004. declare module BABYLON {
  78005. /**
  78006. * Class used to represent a sprite
  78007. * @see http://doc.babylonjs.com/babylon101/sprites
  78008. */
  78009. export class Sprite {
  78010. /** defines the name */
  78011. name: string;
  78012. /** Gets or sets the current world position */
  78013. position: Vector3;
  78014. /** Gets or sets the main color */
  78015. color: Color4;
  78016. /** Gets or sets the width */
  78017. width: number;
  78018. /** Gets or sets the height */
  78019. height: number;
  78020. /** Gets or sets rotation angle */
  78021. angle: number;
  78022. /** Gets or sets the cell index in the sprite sheet */
  78023. cellIndex: number;
  78024. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  78025. cellRef: string;
  78026. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78027. invertU: number;
  78028. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78029. invertV: number;
  78030. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78031. disposeWhenFinishedAnimating: boolean;
  78032. /** Gets the list of attached animations */
  78033. animations: Animation[];
  78034. /** Gets or sets a boolean indicating if the sprite can be picked */
  78035. isPickable: boolean;
  78036. /**
  78037. * Gets or sets the associated action manager
  78038. */
  78039. actionManager: Nullable<ActionManager>;
  78040. private _animationStarted;
  78041. private _loopAnimation;
  78042. private _fromIndex;
  78043. private _toIndex;
  78044. private _delay;
  78045. private _direction;
  78046. private _manager;
  78047. private _time;
  78048. private _onAnimationEnd;
  78049. /**
  78050. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78051. */
  78052. isVisible: boolean;
  78053. /**
  78054. * Gets or sets the sprite size
  78055. */
  78056. size: number;
  78057. /**
  78058. * Creates a new Sprite
  78059. * @param name defines the name
  78060. * @param manager defines the manager
  78061. */
  78062. constructor(
  78063. /** defines the name */
  78064. name: string, manager: ISpriteManager);
  78065. /**
  78066. * Starts an animation
  78067. * @param from defines the initial key
  78068. * @param to defines the end key
  78069. * @param loop defines if the animation must loop
  78070. * @param delay defines the start delay (in ms)
  78071. * @param onAnimationEnd defines a callback to call when animation ends
  78072. */
  78073. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78074. /** Stops current animation (if any) */
  78075. stopAnimation(): void;
  78076. /** @hidden */
  78077. _animate(deltaTime: number): void;
  78078. /** Release associated resources */
  78079. dispose(): void;
  78080. }
  78081. }
  78082. declare module BABYLON {
  78083. /**
  78084. * Information about the result of picking within a scene
  78085. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  78086. */
  78087. export class PickingInfo {
  78088. /** @hidden */
  78089. _pickingUnavailable: boolean;
  78090. /**
  78091. * If the pick collided with an object
  78092. */
  78093. hit: boolean;
  78094. /**
  78095. * Distance away where the pick collided
  78096. */
  78097. distance: number;
  78098. /**
  78099. * The location of pick collision
  78100. */
  78101. pickedPoint: Nullable<Vector3>;
  78102. /**
  78103. * The mesh corresponding the the pick collision
  78104. */
  78105. pickedMesh: Nullable<AbstractMesh>;
  78106. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  78107. bu: number;
  78108. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  78109. bv: number;
  78110. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  78111. faceId: number;
  78112. /** Id of the the submesh that was picked */
  78113. subMeshId: number;
  78114. /** If a sprite was picked, this will be the sprite the pick collided with */
  78115. pickedSprite: Nullable<Sprite>;
  78116. /**
  78117. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  78118. */
  78119. originMesh: Nullable<AbstractMesh>;
  78120. /**
  78121. * The ray that was used to perform the picking.
  78122. */
  78123. ray: Nullable<Ray>;
  78124. /**
  78125. * Gets the normal correspodning to the face the pick collided with
  78126. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  78127. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  78128. * @returns The normal correspodning to the face the pick collided with
  78129. */
  78130. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  78131. /**
  78132. * Gets the texture coordinates of where the pick occured
  78133. * @returns the vector containing the coordnates of the texture
  78134. */
  78135. getTextureCoordinates(): Nullable<Vector2>;
  78136. }
  78137. }
  78138. declare module BABYLON {
  78139. /**
  78140. * Gather the list of pointer event types as constants.
  78141. */
  78142. export class PointerEventTypes {
  78143. /**
  78144. * 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.
  78145. */
  78146. static readonly POINTERDOWN: number;
  78147. /**
  78148. * The pointerup event is fired when a pointer is no longer active.
  78149. */
  78150. static readonly POINTERUP: number;
  78151. /**
  78152. * The pointermove event is fired when a pointer changes coordinates.
  78153. */
  78154. static readonly POINTERMOVE: number;
  78155. /**
  78156. * The pointerwheel event is fired when a mouse wheel has been rotated.
  78157. */
  78158. static readonly POINTERWHEEL: number;
  78159. /**
  78160. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  78161. */
  78162. static readonly POINTERPICK: number;
  78163. /**
  78164. * The pointertap event is fired when a the object has been touched and released without drag.
  78165. */
  78166. static readonly POINTERTAP: number;
  78167. /**
  78168. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  78169. */
  78170. static readonly POINTERDOUBLETAP: number;
  78171. }
  78172. /**
  78173. * Base class of pointer info types.
  78174. */
  78175. export class PointerInfoBase {
  78176. /**
  78177. * Defines the type of event (PointerEventTypes)
  78178. */
  78179. type: number;
  78180. /**
  78181. * Defines the related dom event
  78182. */
  78183. event: PointerEvent | MouseWheelEvent;
  78184. /**
  78185. * Instantiates the base class of pointers info.
  78186. * @param type Defines the type of event (PointerEventTypes)
  78187. * @param event Defines the related dom event
  78188. */
  78189. constructor(
  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. /**
  78200. * This class is used to store pointer related info for the onPrePointerObservable event.
  78201. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  78202. */
  78203. export class PointerInfoPre extends PointerInfoBase {
  78204. /**
  78205. * Ray from a pointer if availible (eg. 6dof controller)
  78206. */
  78207. ray: Nullable<Ray>;
  78208. /**
  78209. * Defines the local position of the pointer on the canvas.
  78210. */
  78211. localPosition: Vector2;
  78212. /**
  78213. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  78214. */
  78215. skipOnPointerObservable: boolean;
  78216. /**
  78217. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  78218. * @param type Defines the type of event (PointerEventTypes)
  78219. * @param event Defines the related dom event
  78220. * @param localX Defines the local x coordinates of the pointer when the event occured
  78221. * @param localY Defines the local y coordinates of the pointer when the event occured
  78222. */
  78223. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  78224. }
  78225. /**
  78226. * This type contains all the data related to a pointer event in Babylon.js.
  78227. * 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.
  78228. */
  78229. export class PointerInfo extends PointerInfoBase {
  78230. /**
  78231. * Defines the picking info associated to the info (if any)\
  78232. */
  78233. pickInfo: Nullable<PickingInfo>;
  78234. /**
  78235. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  78236. * @param type Defines the type of event (PointerEventTypes)
  78237. * @param event Defines the related dom event
  78238. * @param pickInfo Defines the picking info associated to the info (if any)\
  78239. */
  78240. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  78241. /**
  78242. * Defines the picking info associated to the info (if any)\
  78243. */
  78244. pickInfo: Nullable<PickingInfo>);
  78245. }
  78246. /**
  78247. * Data relating to a touch event on the screen.
  78248. */
  78249. export interface PointerTouch {
  78250. /**
  78251. * X coordinate of touch.
  78252. */
  78253. x: number;
  78254. /**
  78255. * Y coordinate of touch.
  78256. */
  78257. y: number;
  78258. /**
  78259. * Id of touch. Unique for each finger.
  78260. */
  78261. pointerId: number;
  78262. /**
  78263. * Event type passed from DOM.
  78264. */
  78265. type: any;
  78266. }
  78267. }
  78268. declare module BABYLON {
  78269. /**
  78270. * Manage the mouse inputs to control the movement of a free camera.
  78271. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78272. */
  78273. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  78274. /**
  78275. * Define if touch is enabled in the mouse input
  78276. */
  78277. touchEnabled: boolean;
  78278. /**
  78279. * Defines the camera the input is attached to.
  78280. */
  78281. camera: FreeCamera;
  78282. /**
  78283. * Defines the buttons associated with the input to handle camera move.
  78284. */
  78285. buttons: number[];
  78286. /**
  78287. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  78288. */
  78289. angularSensibility: number;
  78290. private _pointerInput;
  78291. private _onMouseMove;
  78292. private _observer;
  78293. private previousPosition;
  78294. /**
  78295. * Observable for when a pointer move event occurs containing the move offset
  78296. */
  78297. onPointerMovedObservable: Observable<{
  78298. offsetX: number;
  78299. offsetY: number;
  78300. }>;
  78301. /**
  78302. * @hidden
  78303. * If the camera should be rotated automatically based on pointer movement
  78304. */
  78305. _allowCameraRotation: boolean;
  78306. /**
  78307. * Manage the mouse inputs to control the movement of a free camera.
  78308. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78309. * @param touchEnabled Defines if touch is enabled or not
  78310. */
  78311. constructor(
  78312. /**
  78313. * Define if touch is enabled in the mouse input
  78314. */
  78315. touchEnabled?: boolean);
  78316. /**
  78317. * Attach the input controls to a specific dom element to get the input from.
  78318. * @param element Defines the element the controls should be listened from
  78319. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78320. */
  78321. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78322. /**
  78323. * Called on JS contextmenu event.
  78324. * Override this method to provide functionality.
  78325. */
  78326. protected onContextMenu(evt: PointerEvent): void;
  78327. /**
  78328. * Detach the current controls from the specified dom element.
  78329. * @param element Defines the element to stop listening the inputs from
  78330. */
  78331. detachControl(element: Nullable<HTMLElement>): void;
  78332. /**
  78333. * Gets the class name of the current intput.
  78334. * @returns the class name
  78335. */
  78336. getClassName(): string;
  78337. /**
  78338. * Get the friendly name associated with the input class.
  78339. * @returns the input friendly name
  78340. */
  78341. getSimpleName(): string;
  78342. }
  78343. }
  78344. declare module BABYLON {
  78345. /**
  78346. * Manage the touch inputs to control the movement of a free camera.
  78347. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78348. */
  78349. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  78350. /**
  78351. * Defines the camera the input is attached to.
  78352. */
  78353. camera: FreeCamera;
  78354. /**
  78355. * Defines the touch sensibility for rotation.
  78356. * The higher the faster.
  78357. */
  78358. touchAngularSensibility: number;
  78359. /**
  78360. * Defines the touch sensibility for move.
  78361. * The higher the faster.
  78362. */
  78363. touchMoveSensibility: number;
  78364. private _offsetX;
  78365. private _offsetY;
  78366. private _pointerPressed;
  78367. private _pointerInput;
  78368. private _observer;
  78369. private _onLostFocus;
  78370. /**
  78371. * Attach the input controls to a specific dom element to get the input from.
  78372. * @param element Defines the element the controls should be listened from
  78373. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78374. */
  78375. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78376. /**
  78377. * Detach the current controls from the specified dom element.
  78378. * @param element Defines the element to stop listening the inputs from
  78379. */
  78380. detachControl(element: Nullable<HTMLElement>): void;
  78381. /**
  78382. * Update the current camera state depending on the inputs that have been used this frame.
  78383. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78384. */
  78385. checkInputs(): void;
  78386. /**
  78387. * Gets the class name of the current intput.
  78388. * @returns the class name
  78389. */
  78390. getClassName(): string;
  78391. /**
  78392. * Get the friendly name associated with the input class.
  78393. * @returns the input friendly name
  78394. */
  78395. getSimpleName(): string;
  78396. }
  78397. }
  78398. declare module BABYLON {
  78399. /**
  78400. * Default Inputs manager for the FreeCamera.
  78401. * It groups all the default supported inputs for ease of use.
  78402. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78403. */
  78404. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  78405. /**
  78406. * @hidden
  78407. */
  78408. _mouseInput: Nullable<FreeCameraMouseInput>;
  78409. /**
  78410. * Instantiates a new FreeCameraInputsManager.
  78411. * @param camera Defines the camera the inputs belong to
  78412. */
  78413. constructor(camera: FreeCamera);
  78414. /**
  78415. * Add keyboard input support to the input manager.
  78416. * @returns the current input manager
  78417. */
  78418. addKeyboard(): FreeCameraInputsManager;
  78419. /**
  78420. * Add mouse input support to the input manager.
  78421. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  78422. * @returns the current input manager
  78423. */
  78424. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  78425. /**
  78426. * Removes the mouse input support from the manager
  78427. * @returns the current input manager
  78428. */
  78429. removeMouse(): FreeCameraInputsManager;
  78430. /**
  78431. * Add touch input support to the input manager.
  78432. * @returns the current input manager
  78433. */
  78434. addTouch(): FreeCameraInputsManager;
  78435. /**
  78436. * Remove all attached input methods from a camera
  78437. */
  78438. clear(): void;
  78439. }
  78440. }
  78441. declare module BABYLON {
  78442. /**
  78443. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78444. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  78445. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78446. */
  78447. export class FreeCamera extends TargetCamera {
  78448. /**
  78449. * Define the collision ellipsoid of the camera.
  78450. * This is helpful to simulate a camera body like the player body around the camera
  78451. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  78452. */
  78453. ellipsoid: Vector3;
  78454. /**
  78455. * Define an offset for the position of the ellipsoid around the camera.
  78456. * This can be helpful to determine the center of the body near the gravity center of the body
  78457. * instead of its head.
  78458. */
  78459. ellipsoidOffset: Vector3;
  78460. /**
  78461. * Enable or disable collisions of the camera with the rest of the scene objects.
  78462. */
  78463. checkCollisions: boolean;
  78464. /**
  78465. * Enable or disable gravity on the camera.
  78466. */
  78467. applyGravity: boolean;
  78468. /**
  78469. * Define the input manager associated to the camera.
  78470. */
  78471. inputs: FreeCameraInputsManager;
  78472. /**
  78473. * Gets the input sensibility for a mouse input. (default is 2000.0)
  78474. * Higher values reduce sensitivity.
  78475. */
  78476. /**
  78477. * Sets the input sensibility for a mouse input. (default is 2000.0)
  78478. * Higher values reduce sensitivity.
  78479. */
  78480. angularSensibility: number;
  78481. /**
  78482. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  78483. */
  78484. keysUp: number[];
  78485. /**
  78486. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  78487. */
  78488. keysDown: number[];
  78489. /**
  78490. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  78491. */
  78492. keysLeft: number[];
  78493. /**
  78494. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  78495. */
  78496. keysRight: number[];
  78497. /**
  78498. * Event raised when the camera collide with a mesh in the scene.
  78499. */
  78500. onCollide: (collidedMesh: AbstractMesh) => void;
  78501. private _collider;
  78502. private _needMoveForGravity;
  78503. private _oldPosition;
  78504. private _diffPosition;
  78505. private _newPosition;
  78506. /** @hidden */
  78507. _localDirection: Vector3;
  78508. /** @hidden */
  78509. _transformedDirection: Vector3;
  78510. /**
  78511. * Instantiates a Free Camera.
  78512. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78513. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  78514. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78515. * @param name Define the name of the camera in the scene
  78516. * @param position Define the start position of the camera in the scene
  78517. * @param scene Define the scene the camera belongs to
  78518. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  78519. */
  78520. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  78521. /**
  78522. * Attached controls to the current camera.
  78523. * @param element Defines the element the controls should be listened from
  78524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78525. */
  78526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78527. /**
  78528. * Detach the current controls from the camera.
  78529. * The camera will stop reacting to inputs.
  78530. * @param element Defines the element to stop listening the inputs from
  78531. */
  78532. detachControl(element: HTMLElement): void;
  78533. private _collisionMask;
  78534. /**
  78535. * Define a collision mask to limit the list of object the camera can collide with
  78536. */
  78537. collisionMask: number;
  78538. /** @hidden */
  78539. _collideWithWorld(displacement: Vector3): void;
  78540. private _onCollisionPositionChange;
  78541. /** @hidden */
  78542. _checkInputs(): void;
  78543. /** @hidden */
  78544. _decideIfNeedsToMove(): boolean;
  78545. /** @hidden */
  78546. _updatePosition(): void;
  78547. /**
  78548. * Destroy the camera and release the current resources hold by it.
  78549. */
  78550. dispose(): void;
  78551. /**
  78552. * Gets the current object class name.
  78553. * @return the class name
  78554. */
  78555. getClassName(): string;
  78556. }
  78557. }
  78558. declare module BABYLON {
  78559. /**
  78560. * Represents a gamepad control stick position
  78561. */
  78562. export class StickValues {
  78563. /**
  78564. * The x component of the control stick
  78565. */
  78566. x: number;
  78567. /**
  78568. * The y component of the control stick
  78569. */
  78570. y: number;
  78571. /**
  78572. * Initializes the gamepad x and y control stick values
  78573. * @param x The x component of the gamepad control stick value
  78574. * @param y The y component of the gamepad control stick value
  78575. */
  78576. constructor(
  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. /**
  78587. * An interface which manages callbacks for gamepad button changes
  78588. */
  78589. export interface GamepadButtonChanges {
  78590. /**
  78591. * Called when a gamepad has been changed
  78592. */
  78593. changed: boolean;
  78594. /**
  78595. * Called when a gamepad press event has been triggered
  78596. */
  78597. pressChanged: boolean;
  78598. /**
  78599. * Called when a touch event has been triggered
  78600. */
  78601. touchChanged: boolean;
  78602. /**
  78603. * Called when a value has changed
  78604. */
  78605. valueChanged: boolean;
  78606. }
  78607. /**
  78608. * Represents a gamepad
  78609. */
  78610. export class Gamepad {
  78611. /**
  78612. * The id of the gamepad
  78613. */
  78614. id: string;
  78615. /**
  78616. * The index of the gamepad
  78617. */
  78618. index: number;
  78619. /**
  78620. * The browser gamepad
  78621. */
  78622. browserGamepad: any;
  78623. /**
  78624. * Specifies what type of gamepad this represents
  78625. */
  78626. type: number;
  78627. private _leftStick;
  78628. private _rightStick;
  78629. /** @hidden */
  78630. _isConnected: boolean;
  78631. private _leftStickAxisX;
  78632. private _leftStickAxisY;
  78633. private _rightStickAxisX;
  78634. private _rightStickAxisY;
  78635. /**
  78636. * Triggered when the left control stick has been changed
  78637. */
  78638. private _onleftstickchanged;
  78639. /**
  78640. * Triggered when the right control stick has been changed
  78641. */
  78642. private _onrightstickchanged;
  78643. /**
  78644. * Represents a gamepad controller
  78645. */
  78646. static GAMEPAD: number;
  78647. /**
  78648. * Represents a generic controller
  78649. */
  78650. static GENERIC: number;
  78651. /**
  78652. * Represents an XBox controller
  78653. */
  78654. static XBOX: number;
  78655. /**
  78656. * Represents a pose-enabled controller
  78657. */
  78658. static POSE_ENABLED: number;
  78659. /**
  78660. * Represents an Dual Shock controller
  78661. */
  78662. static DUALSHOCK: number;
  78663. /**
  78664. * Specifies whether the left control stick should be Y-inverted
  78665. */
  78666. protected _invertLeftStickY: boolean;
  78667. /**
  78668. * Specifies if the gamepad has been connected
  78669. */
  78670. readonly isConnected: boolean;
  78671. /**
  78672. * Initializes the gamepad
  78673. * @param id The id of the gamepad
  78674. * @param index The index of the gamepad
  78675. * @param browserGamepad The browser gamepad
  78676. * @param leftStickX The x component of the left joystick
  78677. * @param leftStickY The y component of the left joystick
  78678. * @param rightStickX The x component of the right joystick
  78679. * @param rightStickY The y component of the right joystick
  78680. */
  78681. constructor(
  78682. /**
  78683. * The id of the gamepad
  78684. */
  78685. id: string,
  78686. /**
  78687. * The index of the gamepad
  78688. */
  78689. index: number,
  78690. /**
  78691. * The browser gamepad
  78692. */
  78693. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  78694. /**
  78695. * Callback triggered when the left joystick has changed
  78696. * @param callback
  78697. */
  78698. onleftstickchanged(callback: (values: StickValues) => void): void;
  78699. /**
  78700. * Callback triggered when the right joystick has changed
  78701. * @param callback
  78702. */
  78703. onrightstickchanged(callback: (values: StickValues) => void): void;
  78704. /**
  78705. * Gets the left joystick
  78706. */
  78707. /**
  78708. * Sets the left joystick values
  78709. */
  78710. leftStick: StickValues;
  78711. /**
  78712. * Gets the right joystick
  78713. */
  78714. /**
  78715. * Sets the right joystick value
  78716. */
  78717. rightStick: StickValues;
  78718. /**
  78719. * Updates the gamepad joystick positions
  78720. */
  78721. update(): void;
  78722. /**
  78723. * Disposes the gamepad
  78724. */
  78725. dispose(): void;
  78726. }
  78727. /**
  78728. * Represents a generic gamepad
  78729. */
  78730. export class GenericPad extends Gamepad {
  78731. private _buttons;
  78732. private _onbuttondown;
  78733. private _onbuttonup;
  78734. /**
  78735. * Observable triggered when a button has been pressed
  78736. */
  78737. onButtonDownObservable: Observable<number>;
  78738. /**
  78739. * Observable triggered when a button has been released
  78740. */
  78741. onButtonUpObservable: Observable<number>;
  78742. /**
  78743. * Callback triggered when a button has been pressed
  78744. * @param callback Called when a button has been pressed
  78745. */
  78746. onbuttondown(callback: (buttonPressed: number) => void): void;
  78747. /**
  78748. * Callback triggered when a button has been released
  78749. * @param callback Called when a button has been released
  78750. */
  78751. onbuttonup(callback: (buttonReleased: number) => void): void;
  78752. /**
  78753. * Initializes the generic gamepad
  78754. * @param id The id of the generic gamepad
  78755. * @param index The index of the generic gamepad
  78756. * @param browserGamepad The browser gamepad
  78757. */
  78758. constructor(id: string, index: number, browserGamepad: any);
  78759. private _setButtonValue;
  78760. /**
  78761. * Updates the generic gamepad
  78762. */
  78763. update(): void;
  78764. /**
  78765. * Disposes the generic gamepad
  78766. */
  78767. dispose(): void;
  78768. }
  78769. }
  78770. declare module BABYLON {
  78771. interface Engine {
  78772. /**
  78773. * Creates a raw texture
  78774. * @param data defines the data to store in the texture
  78775. * @param width defines the width of the texture
  78776. * @param height defines the height of the texture
  78777. * @param format defines the format of the data
  78778. * @param generateMipMaps defines if the engine should generate the mip levels
  78779. * @param invertY defines if data must be stored with Y axis inverted
  78780. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78781. * @param compression defines the compression used (null by default)
  78782. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78783. * @returns the raw texture inside an InternalTexture
  78784. */
  78785. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78786. /**
  78787. * Update a raw texture
  78788. * @param texture defines the texture to update
  78789. * @param data defines the data to store in the texture
  78790. * @param format defines the format of the data
  78791. * @param invertY defines if data must be stored with Y axis inverted
  78792. */
  78793. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78794. /**
  78795. * Update a raw texture
  78796. * @param texture defines the texture to update
  78797. * @param data defines the data to store in the texture
  78798. * @param format defines the format of the data
  78799. * @param invertY defines if data must be stored with Y axis inverted
  78800. * @param compression defines the compression used (null by default)
  78801. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78802. */
  78803. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78804. /**
  78805. * Creates a new raw cube texture
  78806. * @param data defines the array of data to use to create each face
  78807. * @param size defines the size of the textures
  78808. * @param format defines the format of the data
  78809. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78810. * @param generateMipMaps defines if the engine should generate the mip levels
  78811. * @param invertY defines if data must be stored with Y axis inverted
  78812. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78813. * @param compression defines the compression used (null by default)
  78814. * @returns the cube texture as an InternalTexture
  78815. */
  78816. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78817. /**
  78818. * Update a raw cube texture
  78819. * @param texture defines the texture to udpdate
  78820. * @param data defines the data to store
  78821. * @param format defines the data format
  78822. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78823. * @param invertY defines if data must be stored with Y axis inverted
  78824. */
  78825. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78826. /**
  78827. * Update a raw cube texture
  78828. * @param texture defines the texture to udpdate
  78829. * @param data defines the data to store
  78830. * @param format defines the data format
  78831. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78832. * @param invertY defines if data must be stored with Y axis inverted
  78833. * @param compression defines the compression used (null by default)
  78834. */
  78835. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78836. /**
  78837. * Update a raw cube texture
  78838. * @param texture defines the texture to udpdate
  78839. * @param data defines the data to store
  78840. * @param format defines the data format
  78841. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78842. * @param invertY defines if data must be stored with Y axis inverted
  78843. * @param compression defines the compression used (null by default)
  78844. * @param level defines which level of the texture to update
  78845. */
  78846. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78847. /**
  78848. * Creates a new raw cube texture from a specified url
  78849. * @param url defines the url where the data is located
  78850. * @param scene defines the current scene
  78851. * @param size defines the size of the textures
  78852. * @param format defines the format of the data
  78853. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78854. * @param noMipmap defines if the engine should avoid generating the mip levels
  78855. * @param callback defines a callback used to extract texture data from loaded data
  78856. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78857. * @param onLoad defines a callback called when texture is loaded
  78858. * @param onError defines a callback called if there is an error
  78859. * @returns the cube texture as an InternalTexture
  78860. */
  78861. 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;
  78862. /**
  78863. * Creates a new raw cube texture from a specified url
  78864. * @param url defines the url where the data is located
  78865. * @param scene defines the current scene
  78866. * @param size defines the size of the textures
  78867. * @param format defines the format of the data
  78868. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78869. * @param noMipmap defines if the engine should avoid generating the mip levels
  78870. * @param callback defines a callback used to extract texture data from loaded data
  78871. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78872. * @param onLoad defines a callback called when texture is loaded
  78873. * @param onError defines a callback called if there is an error
  78874. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78875. * @param invertY defines if data must be stored with Y axis inverted
  78876. * @returns the cube texture as an InternalTexture
  78877. */
  78878. 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;
  78879. /**
  78880. * Creates a new raw 3D texture
  78881. * @param data defines the data used to create the texture
  78882. * @param width defines the width of the texture
  78883. * @param height defines the height of the texture
  78884. * @param depth defines the depth of the texture
  78885. * @param format defines the format of the texture
  78886. * @param generateMipMaps defines if the engine must generate mip levels
  78887. * @param invertY defines if data must be stored with Y axis inverted
  78888. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78889. * @param compression defines the compressed used (can be null)
  78890. * @param textureType defines the compressed used (can be null)
  78891. * @returns a new raw 3D texture (stored in an InternalTexture)
  78892. */
  78893. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78894. /**
  78895. * Update a raw 3D texture
  78896. * @param texture defines the texture to update
  78897. * @param data defines the data to store
  78898. * @param format defines the data format
  78899. * @param invertY defines if data must be stored with Y axis inverted
  78900. */
  78901. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78902. /**
  78903. * Update a raw 3D texture
  78904. * @param texture defines the texture to update
  78905. * @param data defines the data to store
  78906. * @param format defines the data format
  78907. * @param invertY defines if data must be stored with Y axis inverted
  78908. * @param compression defines the used compression (can be null)
  78909. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78910. */
  78911. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78912. }
  78913. }
  78914. declare module BABYLON {
  78915. /**
  78916. * Raw texture can help creating a texture directly from an array of data.
  78917. * This can be super useful if you either get the data from an uncompressed source or
  78918. * if you wish to create your texture pixel by pixel.
  78919. */
  78920. export class RawTexture extends Texture {
  78921. /**
  78922. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78923. */
  78924. format: number;
  78925. private _engine;
  78926. /**
  78927. * Instantiates a new RawTexture.
  78928. * Raw texture can help creating a texture directly from an array of data.
  78929. * This can be super useful if you either get the data from an uncompressed source or
  78930. * if you wish to create your texture pixel by pixel.
  78931. * @param data define the array of data to use to create the texture
  78932. * @param width define the width of the texture
  78933. * @param height define the height of the texture
  78934. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78935. * @param scene define the scene the texture belongs to
  78936. * @param generateMipMaps define whether mip maps should be generated or not
  78937. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78938. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78939. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78940. */
  78941. constructor(data: ArrayBufferView, width: number, height: number,
  78942. /**
  78943. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78944. */
  78945. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78946. /**
  78947. * Updates the texture underlying data.
  78948. * @param data Define the new data of the texture
  78949. */
  78950. update(data: ArrayBufferView): void;
  78951. /**
  78952. * Creates a luminance texture from some data.
  78953. * @param data Define the texture data
  78954. * @param width Define the width of the texture
  78955. * @param height Define the height of the texture
  78956. * @param scene Define the scene the texture belongs to
  78957. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78958. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78959. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78960. * @returns the luminance texture
  78961. */
  78962. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78963. /**
  78964. * Creates a luminance alpha texture from some data.
  78965. * @param data Define the texture data
  78966. * @param width Define the width of the texture
  78967. * @param height Define the height of the texture
  78968. * @param scene Define the scene the texture belongs to
  78969. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78970. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78971. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78972. * @returns the luminance alpha texture
  78973. */
  78974. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78975. /**
  78976. * Creates an alpha texture from some data.
  78977. * @param data Define the texture data
  78978. * @param width Define the width of the texture
  78979. * @param height Define the height of the texture
  78980. * @param scene Define the scene the texture belongs to
  78981. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78982. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78983. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78984. * @returns the alpha texture
  78985. */
  78986. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78987. /**
  78988. * Creates a RGB texture from some data.
  78989. * @param data Define the texture data
  78990. * @param width Define the width of the texture
  78991. * @param height Define the height of the texture
  78992. * @param scene Define the scene the texture belongs to
  78993. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78994. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78995. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78996. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78997. * @returns the RGB alpha texture
  78998. */
  78999. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79000. /**
  79001. * Creates a RGBA texture from some data.
  79002. * @param data Define the texture data
  79003. * @param width Define the width of the texture
  79004. * @param height Define the height of the texture
  79005. * @param scene Define the scene the texture belongs to
  79006. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79007. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79008. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79009. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79010. * @returns the RGBA texture
  79011. */
  79012. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79013. /**
  79014. * Creates a R texture from some data.
  79015. * @param data Define the texture data
  79016. * @param width Define the width of the texture
  79017. * @param height Define the height of the texture
  79018. * @param scene Define the scene the texture belongs to
  79019. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79020. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79021. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79022. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79023. * @returns the R texture
  79024. */
  79025. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79026. }
  79027. }
  79028. declare module BABYLON {
  79029. /**
  79030. * Interface for the size containing width and height
  79031. */
  79032. export interface ISize {
  79033. /**
  79034. * Width
  79035. */
  79036. width: number;
  79037. /**
  79038. * Heighht
  79039. */
  79040. height: number;
  79041. }
  79042. /**
  79043. * Size containing widht and height
  79044. */
  79045. export class Size implements ISize {
  79046. /**
  79047. * Width
  79048. */
  79049. width: number;
  79050. /**
  79051. * Height
  79052. */
  79053. height: number;
  79054. /**
  79055. * Creates a Size object from the given width and height (floats).
  79056. * @param width width of the new size
  79057. * @param height height of the new size
  79058. */
  79059. constructor(width: number, height: number);
  79060. /**
  79061. * Returns a string with the Size width and height
  79062. * @returns a string with the Size width and height
  79063. */
  79064. toString(): string;
  79065. /**
  79066. * "Size"
  79067. * @returns the string "Size"
  79068. */
  79069. getClassName(): string;
  79070. /**
  79071. * Returns the Size hash code.
  79072. * @returns a hash code for a unique width and height
  79073. */
  79074. getHashCode(): number;
  79075. /**
  79076. * Updates the current size from the given one.
  79077. * @param src the given size
  79078. */
  79079. copyFrom(src: Size): void;
  79080. /**
  79081. * Updates in place the current Size from the given floats.
  79082. * @param width width of the new size
  79083. * @param height height of the new size
  79084. * @returns the updated Size.
  79085. */
  79086. copyFromFloats(width: number, height: number): Size;
  79087. /**
  79088. * Updates in place the current Size from the given floats.
  79089. * @param width width to set
  79090. * @param height height to set
  79091. * @returns the updated Size.
  79092. */
  79093. set(width: number, height: number): Size;
  79094. /**
  79095. * Multiplies the width and height by numbers
  79096. * @param w factor to multiple the width by
  79097. * @param h factor to multiple the height by
  79098. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  79099. */
  79100. multiplyByFloats(w: number, h: number): Size;
  79101. /**
  79102. * Clones the size
  79103. * @returns a new Size copied from the given one.
  79104. */
  79105. clone(): Size;
  79106. /**
  79107. * True if the current Size and the given one width and height are strictly equal.
  79108. * @param other the other size to compare against
  79109. * @returns True if the current Size and the given one width and height are strictly equal.
  79110. */
  79111. equals(other: Size): boolean;
  79112. /**
  79113. * The surface of the Size : width * height (float).
  79114. */
  79115. readonly surface: number;
  79116. /**
  79117. * Create a new size of zero
  79118. * @returns a new Size set to (0.0, 0.0)
  79119. */
  79120. static Zero(): Size;
  79121. /**
  79122. * Sums the width and height of two sizes
  79123. * @param otherSize size to add to this size
  79124. * @returns a new Size set as the addition result of the current Size and the given one.
  79125. */
  79126. add(otherSize: Size): Size;
  79127. /**
  79128. * Subtracts the width and height of two
  79129. * @param otherSize size to subtract to this size
  79130. * @returns a new Size set as the subtraction result of the given one from the current Size.
  79131. */
  79132. subtract(otherSize: Size): Size;
  79133. /**
  79134. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  79135. * @param start starting size to lerp between
  79136. * @param end end size to lerp between
  79137. * @param amount amount to lerp between the start and end values
  79138. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  79139. */
  79140. static Lerp(start: Size, end: Size, amount: number): Size;
  79141. }
  79142. }
  79143. declare module BABYLON {
  79144. /**
  79145. * Defines a runtime animation
  79146. */
  79147. export class RuntimeAnimation {
  79148. private _events;
  79149. /**
  79150. * The current frame of the runtime animation
  79151. */
  79152. private _currentFrame;
  79153. /**
  79154. * The animation used by the runtime animation
  79155. */
  79156. private _animation;
  79157. /**
  79158. * The target of the runtime animation
  79159. */
  79160. private _target;
  79161. /**
  79162. * The initiating animatable
  79163. */
  79164. private _host;
  79165. /**
  79166. * The original value of the runtime animation
  79167. */
  79168. private _originalValue;
  79169. /**
  79170. * The original blend value of the runtime animation
  79171. */
  79172. private _originalBlendValue;
  79173. /**
  79174. * The offsets cache of the runtime animation
  79175. */
  79176. private _offsetsCache;
  79177. /**
  79178. * The high limits cache of the runtime animation
  79179. */
  79180. private _highLimitsCache;
  79181. /**
  79182. * Specifies if the runtime animation has been stopped
  79183. */
  79184. private _stopped;
  79185. /**
  79186. * The blending factor of the runtime animation
  79187. */
  79188. private _blendingFactor;
  79189. /**
  79190. * The BabylonJS scene
  79191. */
  79192. private _scene;
  79193. /**
  79194. * The current value of the runtime animation
  79195. */
  79196. private _currentValue;
  79197. /** @hidden */
  79198. _animationState: _IAnimationState;
  79199. /**
  79200. * The active target of the runtime animation
  79201. */
  79202. private _activeTargets;
  79203. private _currentActiveTarget;
  79204. private _directTarget;
  79205. /**
  79206. * The target path of the runtime animation
  79207. */
  79208. private _targetPath;
  79209. /**
  79210. * The weight of the runtime animation
  79211. */
  79212. private _weight;
  79213. /**
  79214. * The ratio offset of the runtime animation
  79215. */
  79216. private _ratioOffset;
  79217. /**
  79218. * The previous delay of the runtime animation
  79219. */
  79220. private _previousDelay;
  79221. /**
  79222. * The previous ratio of the runtime animation
  79223. */
  79224. private _previousRatio;
  79225. private _enableBlending;
  79226. private _keys;
  79227. private _minFrame;
  79228. private _maxFrame;
  79229. private _minValue;
  79230. private _maxValue;
  79231. private _targetIsArray;
  79232. /**
  79233. * Gets the current frame of the runtime animation
  79234. */
  79235. readonly currentFrame: number;
  79236. /**
  79237. * Gets the weight of the runtime animation
  79238. */
  79239. readonly weight: number;
  79240. /**
  79241. * Gets the current value of the runtime animation
  79242. */
  79243. readonly currentValue: any;
  79244. /**
  79245. * Gets the target path of the runtime animation
  79246. */
  79247. readonly targetPath: string;
  79248. /**
  79249. * Gets the actual target of the runtime animation
  79250. */
  79251. readonly target: any;
  79252. /** @hidden */
  79253. _onLoop: () => void;
  79254. /**
  79255. * Create a new RuntimeAnimation object
  79256. * @param target defines the target of the animation
  79257. * @param animation defines the source animation object
  79258. * @param scene defines the hosting scene
  79259. * @param host defines the initiating Animatable
  79260. */
  79261. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  79262. private _preparePath;
  79263. /**
  79264. * Gets the animation from the runtime animation
  79265. */
  79266. readonly animation: Animation;
  79267. /**
  79268. * Resets the runtime animation to the beginning
  79269. * @param restoreOriginal defines whether to restore the target property to the original value
  79270. */
  79271. reset(restoreOriginal?: boolean): void;
  79272. /**
  79273. * Specifies if the runtime animation is stopped
  79274. * @returns Boolean specifying if the runtime animation is stopped
  79275. */
  79276. isStopped(): boolean;
  79277. /**
  79278. * Disposes of the runtime animation
  79279. */
  79280. dispose(): void;
  79281. /**
  79282. * Apply the interpolated value to the target
  79283. * @param currentValue defines the value computed by the animation
  79284. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  79285. */
  79286. setValue(currentValue: any, weight: number): void;
  79287. private _getOriginalValues;
  79288. private _setValue;
  79289. /**
  79290. * Gets the loop pmode of the runtime animation
  79291. * @returns Loop Mode
  79292. */
  79293. private _getCorrectLoopMode;
  79294. /**
  79295. * Move the current animation to a given frame
  79296. * @param frame defines the frame to move to
  79297. */
  79298. goToFrame(frame: number): void;
  79299. /**
  79300. * @hidden Internal use only
  79301. */
  79302. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  79303. /**
  79304. * Execute the current animation
  79305. * @param delay defines the delay to add to the current frame
  79306. * @param from defines the lower bound of the animation range
  79307. * @param to defines the upper bound of the animation range
  79308. * @param loop defines if the current animation must loop
  79309. * @param speedRatio defines the current speed ratio
  79310. * @param weight defines the weight of the animation (default is -1 so no weight)
  79311. * @param onLoop optional callback called when animation loops
  79312. * @returns a boolean indicating if the animation is running
  79313. */
  79314. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  79315. }
  79316. }
  79317. declare module BABYLON {
  79318. /**
  79319. * Class used to store an actual running animation
  79320. */
  79321. export class Animatable {
  79322. /** defines the target object */
  79323. target: any;
  79324. /** defines the starting frame number (default is 0) */
  79325. fromFrame: number;
  79326. /** defines the ending frame number (default is 100) */
  79327. toFrame: number;
  79328. /** defines if the animation must loop (default is false) */
  79329. loopAnimation: boolean;
  79330. /** defines a callback to call when animation ends if it is not looping */
  79331. onAnimationEnd?: (() => void) | null | undefined;
  79332. /** defines a callback to call when animation loops */
  79333. onAnimationLoop?: (() => void) | null | undefined;
  79334. private _localDelayOffset;
  79335. private _pausedDelay;
  79336. private _runtimeAnimations;
  79337. private _paused;
  79338. private _scene;
  79339. private _speedRatio;
  79340. private _weight;
  79341. private _syncRoot;
  79342. /**
  79343. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  79344. * This will only apply for non looping animation (default is true)
  79345. */
  79346. disposeOnEnd: boolean;
  79347. /**
  79348. * Gets a boolean indicating if the animation has started
  79349. */
  79350. animationStarted: boolean;
  79351. /**
  79352. * Observer raised when the animation ends
  79353. */
  79354. onAnimationEndObservable: Observable<Animatable>;
  79355. /**
  79356. * Observer raised when the animation loops
  79357. */
  79358. onAnimationLoopObservable: Observable<Animatable>;
  79359. /**
  79360. * Gets the root Animatable used to synchronize and normalize animations
  79361. */
  79362. readonly syncRoot: Nullable<Animatable>;
  79363. /**
  79364. * Gets the current frame of the first RuntimeAnimation
  79365. * Used to synchronize Animatables
  79366. */
  79367. readonly masterFrame: number;
  79368. /**
  79369. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  79370. */
  79371. weight: number;
  79372. /**
  79373. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  79374. */
  79375. speedRatio: number;
  79376. /**
  79377. * Creates a new Animatable
  79378. * @param scene defines the hosting scene
  79379. * @param target defines the target object
  79380. * @param fromFrame defines the starting frame number (default is 0)
  79381. * @param toFrame defines the ending frame number (default is 100)
  79382. * @param loopAnimation defines if the animation must loop (default is false)
  79383. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  79384. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  79385. * @param animations defines a group of animation to add to the new Animatable
  79386. * @param onAnimationLoop defines a callback to call when animation loops
  79387. */
  79388. constructor(scene: Scene,
  79389. /** defines the target object */
  79390. target: any,
  79391. /** defines the starting frame number (default is 0) */
  79392. fromFrame?: number,
  79393. /** defines the ending frame number (default is 100) */
  79394. toFrame?: number,
  79395. /** defines if the animation must loop (default is false) */
  79396. loopAnimation?: boolean, speedRatio?: number,
  79397. /** defines a callback to call when animation ends if it is not looping */
  79398. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  79399. /** defines a callback to call when animation loops */
  79400. onAnimationLoop?: (() => void) | null | undefined);
  79401. /**
  79402. * Synchronize and normalize current Animatable with a source Animatable
  79403. * This is useful when using animation weights and when animations are not of the same length
  79404. * @param root defines the root Animatable to synchronize with
  79405. * @returns the current Animatable
  79406. */
  79407. syncWith(root: Animatable): Animatable;
  79408. /**
  79409. * Gets the list of runtime animations
  79410. * @returns an array of RuntimeAnimation
  79411. */
  79412. getAnimations(): RuntimeAnimation[];
  79413. /**
  79414. * Adds more animations to the current animatable
  79415. * @param target defines the target of the animations
  79416. * @param animations defines the new animations to add
  79417. */
  79418. appendAnimations(target: any, animations: Animation[]): void;
  79419. /**
  79420. * Gets the source animation for a specific property
  79421. * @param property defines the propertyu to look for
  79422. * @returns null or the source animation for the given property
  79423. */
  79424. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  79425. /**
  79426. * Gets the runtime animation for a specific property
  79427. * @param property defines the propertyu to look for
  79428. * @returns null or the runtime animation for the given property
  79429. */
  79430. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  79431. /**
  79432. * Resets the animatable to its original state
  79433. */
  79434. reset(): void;
  79435. /**
  79436. * Allows the animatable to blend with current running animations
  79437. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79438. * @param blendingSpeed defines the blending speed to use
  79439. */
  79440. enableBlending(blendingSpeed: number): void;
  79441. /**
  79442. * Disable animation blending
  79443. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79444. */
  79445. disableBlending(): void;
  79446. /**
  79447. * Jump directly to a given frame
  79448. * @param frame defines the frame to jump to
  79449. */
  79450. goToFrame(frame: number): void;
  79451. /**
  79452. * Pause the animation
  79453. */
  79454. pause(): void;
  79455. /**
  79456. * Restart the animation
  79457. */
  79458. restart(): void;
  79459. private _raiseOnAnimationEnd;
  79460. /**
  79461. * Stop and delete the current animation
  79462. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  79463. * @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)
  79464. */
  79465. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  79466. /**
  79467. * Wait asynchronously for the animation to end
  79468. * @returns a promise which will be fullfilled when the animation ends
  79469. */
  79470. waitAsync(): Promise<Animatable>;
  79471. /** @hidden */
  79472. _animate(delay: number): boolean;
  79473. }
  79474. interface Scene {
  79475. /** @hidden */
  79476. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  79477. /** @hidden */
  79478. _processLateAnimationBindingsForMatrices(holder: {
  79479. totalWeight: number;
  79480. animations: RuntimeAnimation[];
  79481. originalValue: Matrix;
  79482. }): any;
  79483. /** @hidden */
  79484. _processLateAnimationBindingsForQuaternions(holder: {
  79485. totalWeight: number;
  79486. animations: RuntimeAnimation[];
  79487. originalValue: Quaternion;
  79488. }, refQuaternion: Quaternion): Quaternion;
  79489. /** @hidden */
  79490. _processLateAnimationBindings(): void;
  79491. /**
  79492. * Will start the animation sequence of a given target
  79493. * @param target defines the target
  79494. * @param from defines from which frame should animation start
  79495. * @param to defines until which frame should animation run.
  79496. * @param weight defines the weight to apply to the animation (1.0 by default)
  79497. * @param loop defines if the animation loops
  79498. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79499. * @param onAnimationEnd defines the function to be executed when the animation ends
  79500. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79501. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79502. * @param onAnimationLoop defines the callback to call when an animation loops
  79503. * @returns the animatable object created for this animation
  79504. */
  79505. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79506. /**
  79507. * Will start the animation sequence of a given target
  79508. * @param target defines the target
  79509. * @param from defines from which frame should animation start
  79510. * @param to defines until which frame should animation run.
  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 stopCurrent defines if the current animations must be stopped first (true by default)
  79516. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  79517. * @param onAnimationLoop defines the callback to call when an animation loops
  79518. * @returns the animatable object created for this animation
  79519. */
  79520. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79521. /**
  79522. * Will start the animation sequence of a given target and its hierarchy
  79523. * @param target defines the target
  79524. * @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.
  79525. * @param from defines from which frame should animation start
  79526. * @param to defines until which frame should animation run.
  79527. * @param loop defines if the animation loops
  79528. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79529. * @param onAnimationEnd defines the function to be executed when the animation ends
  79530. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79531. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79532. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79533. * @param onAnimationLoop defines the callback to call when an animation loops
  79534. * @returns the list of created animatables
  79535. */
  79536. 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[];
  79537. /**
  79538. * Begin a new animation on a given node
  79539. * @param target defines the target where the animation will take place
  79540. * @param animations defines the list of animations to start
  79541. * @param from defines the initial value
  79542. * @param to defines the final value
  79543. * @param loop defines if you want animation to loop (off by default)
  79544. * @param speedRatio defines the speed ratio to apply to all animations
  79545. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79546. * @param onAnimationLoop defines the callback to call when an animation loops
  79547. * @returns the list of created animatables
  79548. */
  79549. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79550. /**
  79551. * Begin a new animation on a given node and its hierarchy
  79552. * @param target defines the root node where the animation will take place
  79553. * @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.
  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 animatables created for all nodes
  79562. */
  79563. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79564. /**
  79565. * Gets the animatable associated with a specific target
  79566. * @param target defines the target of the animatable
  79567. * @returns the required animatable if found
  79568. */
  79569. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79570. /**
  79571. * Gets all animatables associated with a given target
  79572. * @param target defines the target to look animatables for
  79573. * @returns an array of Animatables
  79574. */
  79575. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79576. /**
  79577. * Stops and removes all animations that have been applied to the scene
  79578. */
  79579. stopAllAnimations(): void;
  79580. }
  79581. interface Bone {
  79582. /**
  79583. * Copy an animation range from another bone
  79584. * @param source defines the source bone
  79585. * @param rangeName defines the range name to copy
  79586. * @param frameOffset defines the frame offset
  79587. * @param rescaleAsRequired defines if rescaling must be applied if required
  79588. * @param skelDimensionsRatio defines the scaling ratio
  79589. * @returns true if operation was successful
  79590. */
  79591. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79592. }
  79593. }
  79594. declare module BABYLON {
  79595. /**
  79596. * Class used to override all child animations of a given target
  79597. */
  79598. export class AnimationPropertiesOverride {
  79599. /**
  79600. * Gets or sets a value indicating if animation blending must be used
  79601. */
  79602. enableBlending: boolean;
  79603. /**
  79604. * Gets or sets the blending speed to use when enableBlending is true
  79605. */
  79606. blendingSpeed: number;
  79607. /**
  79608. * Gets or sets the default loop mode to use
  79609. */
  79610. loopMode: number;
  79611. }
  79612. }
  79613. declare module BABYLON {
  79614. /**
  79615. * Class used to handle skinning animations
  79616. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79617. */
  79618. export class Skeleton implements IAnimatable {
  79619. /** defines the skeleton name */
  79620. name: string;
  79621. /** defines the skeleton Id */
  79622. id: string;
  79623. /**
  79624. * Defines the list of child bones
  79625. */
  79626. bones: Bone[];
  79627. /**
  79628. * Defines an estimate of the dimension of the skeleton at rest
  79629. */
  79630. dimensionsAtRest: Vector3;
  79631. /**
  79632. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79633. */
  79634. needInitialSkinMatrix: boolean;
  79635. /**
  79636. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79637. */
  79638. overrideMesh: Nullable<AbstractMesh>;
  79639. /**
  79640. * Gets the list of animations attached to this skeleton
  79641. */
  79642. animations: Array<Animation>;
  79643. private _scene;
  79644. private _isDirty;
  79645. private _transformMatrices;
  79646. private _transformMatrixTexture;
  79647. private _meshesWithPoseMatrix;
  79648. private _animatables;
  79649. private _identity;
  79650. private _synchronizedWithMesh;
  79651. private _ranges;
  79652. private _lastAbsoluteTransformsUpdateId;
  79653. private _canUseTextureForBones;
  79654. private _uniqueId;
  79655. /** @hidden */
  79656. _numBonesWithLinkedTransformNode: number;
  79657. /** @hidden */
  79658. _hasWaitingData: Nullable<boolean>;
  79659. /**
  79660. * Specifies if the skeleton should be serialized
  79661. */
  79662. doNotSerialize: boolean;
  79663. private _useTextureToStoreBoneMatrices;
  79664. /**
  79665. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79666. * Please note that this option is not available if the hardware does not support it
  79667. */
  79668. useTextureToStoreBoneMatrices: boolean;
  79669. private _animationPropertiesOverride;
  79670. /**
  79671. * Gets or sets the animation properties override
  79672. */
  79673. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79674. /**
  79675. * List of inspectable custom properties (used by the Inspector)
  79676. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79677. */
  79678. inspectableCustomProperties: IInspectable[];
  79679. /**
  79680. * An observable triggered before computing the skeleton's matrices
  79681. */
  79682. onBeforeComputeObservable: Observable<Skeleton>;
  79683. /**
  79684. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79685. */
  79686. readonly isUsingTextureForMatrices: boolean;
  79687. /**
  79688. * Gets the unique ID of this skeleton
  79689. */
  79690. readonly uniqueId: number;
  79691. /**
  79692. * Creates a new skeleton
  79693. * @param name defines the skeleton name
  79694. * @param id defines the skeleton Id
  79695. * @param scene defines the hosting scene
  79696. */
  79697. constructor(
  79698. /** defines the skeleton name */
  79699. name: string,
  79700. /** defines the skeleton Id */
  79701. id: string, scene: Scene);
  79702. /**
  79703. * Gets the current object class name.
  79704. * @return the class name
  79705. */
  79706. getClassName(): string;
  79707. /**
  79708. * Returns an array containing the root bones
  79709. * @returns an array containing the root bones
  79710. */
  79711. getChildren(): Array<Bone>;
  79712. /**
  79713. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79714. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79715. * @returns a Float32Array containing matrices data
  79716. */
  79717. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79718. /**
  79719. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79720. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79721. * @returns a raw texture containing the data
  79722. */
  79723. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  79724. /**
  79725. * Gets the current hosting scene
  79726. * @returns a scene object
  79727. */
  79728. getScene(): Scene;
  79729. /**
  79730. * Gets a string representing the current skeleton data
  79731. * @param fullDetails defines a boolean indicating if we want a verbose version
  79732. * @returns a string representing the current skeleton data
  79733. */
  79734. toString(fullDetails?: boolean): string;
  79735. /**
  79736. * Get bone's index searching by name
  79737. * @param name defines bone's name to search for
  79738. * @return the indice of the bone. Returns -1 if not found
  79739. */
  79740. getBoneIndexByName(name: string): number;
  79741. /**
  79742. * Creater a new animation range
  79743. * @param name defines the name of the range
  79744. * @param from defines the start key
  79745. * @param to defines the end key
  79746. */
  79747. createAnimationRange(name: string, from: number, to: number): void;
  79748. /**
  79749. * Delete a specific animation range
  79750. * @param name defines the name of the range
  79751. * @param deleteFrames defines if frames must be removed as well
  79752. */
  79753. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79754. /**
  79755. * Gets a specific animation range
  79756. * @param name defines the name of the range to look for
  79757. * @returns the requested animation range or null if not found
  79758. */
  79759. getAnimationRange(name: string): Nullable<AnimationRange>;
  79760. /**
  79761. * Gets the list of all animation ranges defined on this skeleton
  79762. * @returns an array
  79763. */
  79764. getAnimationRanges(): Nullable<AnimationRange>[];
  79765. /**
  79766. * Copy animation range from a source skeleton.
  79767. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79768. * @param source defines the source skeleton
  79769. * @param name defines the name of the range to copy
  79770. * @param rescaleAsRequired defines if rescaling must be applied if required
  79771. * @returns true if operation was successful
  79772. */
  79773. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79774. /**
  79775. * Forces the skeleton to go to rest pose
  79776. */
  79777. returnToRest(): void;
  79778. private _getHighestAnimationFrame;
  79779. /**
  79780. * Begin a specific animation range
  79781. * @param name defines the name of the range to start
  79782. * @param loop defines if looping must be turned on (false by default)
  79783. * @param speedRatio defines the speed ratio to apply (1 by default)
  79784. * @param onAnimationEnd defines a callback which will be called when animation will end
  79785. * @returns a new animatable
  79786. */
  79787. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79788. /** @hidden */
  79789. _markAsDirty(): void;
  79790. /** @hidden */
  79791. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79792. /** @hidden */
  79793. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79794. private _computeTransformMatrices;
  79795. /**
  79796. * Build all resources required to render a skeleton
  79797. */
  79798. prepare(): void;
  79799. /**
  79800. * Gets the list of animatables currently running for this skeleton
  79801. * @returns an array of animatables
  79802. */
  79803. getAnimatables(): IAnimatable[];
  79804. /**
  79805. * Clone the current skeleton
  79806. * @param name defines the name of the new skeleton
  79807. * @param id defines the id of the new skeleton
  79808. * @returns the new skeleton
  79809. */
  79810. clone(name: string, id: string): Skeleton;
  79811. /**
  79812. * Enable animation blending for this skeleton
  79813. * @param blendingSpeed defines the blending speed to apply
  79814. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79815. */
  79816. enableBlending(blendingSpeed?: number): void;
  79817. /**
  79818. * Releases all resources associated with the current skeleton
  79819. */
  79820. dispose(): void;
  79821. /**
  79822. * Serialize the skeleton in a JSON object
  79823. * @returns a JSON object
  79824. */
  79825. serialize(): any;
  79826. /**
  79827. * Creates a new skeleton from serialized data
  79828. * @param parsedSkeleton defines the serialized data
  79829. * @param scene defines the hosting scene
  79830. * @returns a new skeleton
  79831. */
  79832. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79833. /**
  79834. * Compute all node absolute transforms
  79835. * @param forceUpdate defines if computation must be done even if cache is up to date
  79836. */
  79837. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79838. /**
  79839. * Gets the root pose matrix
  79840. * @returns a matrix
  79841. */
  79842. getPoseMatrix(): Nullable<Matrix>;
  79843. /**
  79844. * Sorts bones per internal index
  79845. */
  79846. sortBones(): void;
  79847. private _sortBones;
  79848. }
  79849. }
  79850. declare module BABYLON {
  79851. /**
  79852. * Class used to store bone information
  79853. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79854. */
  79855. export class Bone extends Node {
  79856. /**
  79857. * defines the bone name
  79858. */
  79859. name: string;
  79860. private static _tmpVecs;
  79861. private static _tmpQuat;
  79862. private static _tmpMats;
  79863. /**
  79864. * Gets the list of child bones
  79865. */
  79866. children: Bone[];
  79867. /** Gets the animations associated with this bone */
  79868. animations: Animation[];
  79869. /**
  79870. * Gets or sets bone length
  79871. */
  79872. length: number;
  79873. /**
  79874. * @hidden Internal only
  79875. * Set this value to map this bone to a different index in the transform matrices
  79876. * Set this value to -1 to exclude the bone from the transform matrices
  79877. */
  79878. _index: Nullable<number>;
  79879. private _skeleton;
  79880. private _localMatrix;
  79881. private _restPose;
  79882. private _baseMatrix;
  79883. private _absoluteTransform;
  79884. private _invertedAbsoluteTransform;
  79885. private _parent;
  79886. private _scalingDeterminant;
  79887. private _worldTransform;
  79888. private _localScaling;
  79889. private _localRotation;
  79890. private _localPosition;
  79891. private _needToDecompose;
  79892. private _needToCompose;
  79893. /** @hidden */
  79894. _linkedTransformNode: Nullable<TransformNode>;
  79895. /** @hidden */
  79896. _waitingTransformNodeId: Nullable<string>;
  79897. /** @hidden */
  79898. /** @hidden */
  79899. _matrix: Matrix;
  79900. /**
  79901. * Create a new bone
  79902. * @param name defines the bone name
  79903. * @param skeleton defines the parent skeleton
  79904. * @param parentBone defines the parent (can be null if the bone is the root)
  79905. * @param localMatrix defines the local matrix
  79906. * @param restPose defines the rest pose matrix
  79907. * @param baseMatrix defines the base matrix
  79908. * @param index defines index of the bone in the hiearchy
  79909. */
  79910. constructor(
  79911. /**
  79912. * defines the bone name
  79913. */
  79914. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  79915. /**
  79916. * Gets the current object class name.
  79917. * @return the class name
  79918. */
  79919. getClassName(): string;
  79920. /**
  79921. * Gets the parent skeleton
  79922. * @returns a skeleton
  79923. */
  79924. getSkeleton(): Skeleton;
  79925. /**
  79926. * Gets parent bone
  79927. * @returns a bone or null if the bone is the root of the bone hierarchy
  79928. */
  79929. getParent(): Nullable<Bone>;
  79930. /**
  79931. * Returns an array containing the root bones
  79932. * @returns an array containing the root bones
  79933. */
  79934. getChildren(): Array<Bone>;
  79935. /**
  79936. * Sets the parent bone
  79937. * @param parent defines the parent (can be null if the bone is the root)
  79938. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79939. */
  79940. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  79941. /**
  79942. * Gets the local matrix
  79943. * @returns a matrix
  79944. */
  79945. getLocalMatrix(): Matrix;
  79946. /**
  79947. * Gets the base matrix (initial matrix which remains unchanged)
  79948. * @returns a matrix
  79949. */
  79950. getBaseMatrix(): Matrix;
  79951. /**
  79952. * Gets the rest pose matrix
  79953. * @returns a matrix
  79954. */
  79955. getRestPose(): Matrix;
  79956. /**
  79957. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  79958. */
  79959. getWorldMatrix(): Matrix;
  79960. /**
  79961. * Sets the local matrix to rest pose matrix
  79962. */
  79963. returnToRest(): void;
  79964. /**
  79965. * Gets the inverse of the absolute transform matrix.
  79966. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  79967. * @returns a matrix
  79968. */
  79969. getInvertedAbsoluteTransform(): Matrix;
  79970. /**
  79971. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  79972. * @returns a matrix
  79973. */
  79974. getAbsoluteTransform(): Matrix;
  79975. /**
  79976. * Links with the given transform node.
  79977. * The local matrix of this bone is copied from the transform node every frame.
  79978. * @param transformNode defines the transform node to link to
  79979. */
  79980. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  79981. /**
  79982. * Gets the node used to drive the bone's transformation
  79983. * @returns a transform node or null
  79984. */
  79985. getTransformNode(): Nullable<TransformNode>;
  79986. /** Gets or sets current position (in local space) */
  79987. position: Vector3;
  79988. /** Gets or sets current rotation (in local space) */
  79989. rotation: Vector3;
  79990. /** Gets or sets current rotation quaternion (in local space) */
  79991. rotationQuaternion: Quaternion;
  79992. /** Gets or sets current scaling (in local space) */
  79993. scaling: Vector3;
  79994. /**
  79995. * Gets the animation properties override
  79996. */
  79997. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79998. private _decompose;
  79999. private _compose;
  80000. /**
  80001. * Update the base and local matrices
  80002. * @param matrix defines the new base or local matrix
  80003. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80004. * @param updateLocalMatrix defines if the local matrix should be updated
  80005. */
  80006. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80007. /** @hidden */
  80008. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80009. /**
  80010. * Flag the bone as dirty (Forcing it to update everything)
  80011. */
  80012. markAsDirty(): void;
  80013. /** @hidden */
  80014. _markAsDirtyAndCompose(): void;
  80015. private _markAsDirtyAndDecompose;
  80016. /**
  80017. * Translate the bone in local or world space
  80018. * @param vec The amount to translate the bone
  80019. * @param space The space that the translation is in
  80020. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80021. */
  80022. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80023. /**
  80024. * Set the postion of the bone in local or world space
  80025. * @param position The position to set the bone
  80026. * @param space The space that the position is in
  80027. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80028. */
  80029. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80030. /**
  80031. * Set the absolute position of the bone (world space)
  80032. * @param position The position to set the bone
  80033. * @param mesh The mesh that this bone is attached to
  80034. */
  80035. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  80036. /**
  80037. * Scale the bone on the x, y and z axes (in local space)
  80038. * @param x The amount to scale the bone on the x axis
  80039. * @param y The amount to scale the bone on the y axis
  80040. * @param z The amount to scale the bone on the z axis
  80041. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  80042. */
  80043. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  80044. /**
  80045. * Set the bone scaling in local space
  80046. * @param scale defines the scaling vector
  80047. */
  80048. setScale(scale: Vector3): void;
  80049. /**
  80050. * Gets the current scaling in local space
  80051. * @returns the current scaling vector
  80052. */
  80053. getScale(): Vector3;
  80054. /**
  80055. * Gets the current scaling in local space and stores it in a target vector
  80056. * @param result defines the target vector
  80057. */
  80058. getScaleToRef(result: Vector3): void;
  80059. /**
  80060. * Set the yaw, pitch, and roll of the bone in local or world space
  80061. * @param yaw The rotation of the bone on the y axis
  80062. * @param pitch The rotation of the bone on the x axis
  80063. * @param roll The rotation of the bone on the z axis
  80064. * @param space The space that the axes of rotation are in
  80065. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80066. */
  80067. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  80068. /**
  80069. * Add a rotation to the bone on an axis in local or world space
  80070. * @param axis The axis to rotate the bone on
  80071. * @param amount The amount to rotate the bone
  80072. * @param space The space that the axis is in
  80073. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80074. */
  80075. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  80076. /**
  80077. * Set the rotation of the bone to a particular axis angle in local or world space
  80078. * @param axis The axis to rotate the bone on
  80079. * @param angle The angle that the bone should be rotated to
  80080. * @param space The space that the axis is in
  80081. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80082. */
  80083. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  80084. /**
  80085. * Set the euler rotation of the bone in local of world space
  80086. * @param rotation The euler rotation that the bone should be set to
  80087. * @param space The space that the rotation is in
  80088. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80089. */
  80090. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80091. /**
  80092. * Set the quaternion rotation of the bone in local of world space
  80093. * @param quat The quaternion rotation that the bone should be set to
  80094. * @param space The space that the rotation is in
  80095. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80096. */
  80097. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  80098. /**
  80099. * Set the rotation matrix of the bone in local of world space
  80100. * @param rotMat The rotation matrix 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. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  80105. private _rotateWithMatrix;
  80106. private _getNegativeRotationToRef;
  80107. /**
  80108. * Get the position of the bone in local or world space
  80109. * @param space The space that the returned position is in
  80110. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80111. * @returns The position of the bone
  80112. */
  80113. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80114. /**
  80115. * Copy the position of the bone to a vector3 in local or world space
  80116. * @param space The space that the returned position is in
  80117. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80118. * @param result The vector3 to copy the position to
  80119. */
  80120. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  80121. /**
  80122. * Get the absolute position of the bone (world space)
  80123. * @param mesh The mesh that this bone is attached to
  80124. * @returns The absolute position of the bone
  80125. */
  80126. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  80127. /**
  80128. * Copy the absolute position of the bone (world space) to the result param
  80129. * @param mesh The mesh that this bone is attached to
  80130. * @param result The vector3 to copy the absolute position to
  80131. */
  80132. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  80133. /**
  80134. * Compute the absolute transforms of this bone and its children
  80135. */
  80136. computeAbsoluteTransforms(): void;
  80137. /**
  80138. * Get the world direction from an axis that is in the local space of the bone
  80139. * @param localAxis The local direction that is used to compute the world direction
  80140. * @param mesh The mesh that this bone is attached to
  80141. * @returns The world direction
  80142. */
  80143. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80144. /**
  80145. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  80146. * @param localAxis The local direction that is used to compute the world direction
  80147. * @param mesh The mesh that this bone is attached to
  80148. * @param result The vector3 that the world direction will be copied to
  80149. */
  80150. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80151. /**
  80152. * Get the euler rotation of the bone in local or world space
  80153. * @param space The space that the rotation should be in
  80154. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80155. * @returns The euler rotation
  80156. */
  80157. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80158. /**
  80159. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  80160. * @param space The space that the rotation should be in
  80161. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80162. * @param result The vector3 that the rotation should be copied to
  80163. */
  80164. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80165. /**
  80166. * Get the quaternion rotation of the bone in either 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 quaternion rotation
  80170. */
  80171. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  80172. /**
  80173. * Copy the quaternion rotation of the bone to a quaternion. 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 quaternion that the rotation should be copied to
  80177. */
  80178. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  80179. /**
  80180. * Get the rotation matrix of the bone in 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 rotation matrix
  80184. */
  80185. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  80186. /**
  80187. * Copy the rotation matrix of the bone to a matrix. 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. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  80193. /**
  80194. * Get the world position of a point that is in the local space of the bone
  80195. * @param position The local position
  80196. * @param mesh The mesh that this bone is attached to
  80197. * @returns The world position
  80198. */
  80199. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80200. /**
  80201. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  80202. * @param position The local position
  80203. * @param mesh The mesh that this bone is attached to
  80204. * @param result The vector3 that the world position should be copied to
  80205. */
  80206. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80207. /**
  80208. * Get the local position of a point that is in world space
  80209. * @param position The world position
  80210. * @param mesh The mesh that this bone is attached to
  80211. * @returns The local position
  80212. */
  80213. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80214. /**
  80215. * Get the local position of a point that is in world space and copy it to the result param
  80216. * @param position The world position
  80217. * @param mesh The mesh that this bone is attached to
  80218. * @param result The vector3 that the local position should be copied to
  80219. */
  80220. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80221. }
  80222. }
  80223. declare module BABYLON {
  80224. /**
  80225. * 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.
  80226. * @see https://doc.babylonjs.com/how_to/transformnode
  80227. */
  80228. export class TransformNode extends Node {
  80229. /**
  80230. * Object will not rotate to face the camera
  80231. */
  80232. static BILLBOARDMODE_NONE: number;
  80233. /**
  80234. * Object will rotate to face the camera but only on the x axis
  80235. */
  80236. static BILLBOARDMODE_X: number;
  80237. /**
  80238. * Object will rotate to face the camera but only on the y axis
  80239. */
  80240. static BILLBOARDMODE_Y: number;
  80241. /**
  80242. * Object will rotate to face the camera but only on the z axis
  80243. */
  80244. static BILLBOARDMODE_Z: number;
  80245. /**
  80246. * Object will rotate to face the camera
  80247. */
  80248. static BILLBOARDMODE_ALL: number;
  80249. /**
  80250. * Object will rotate to face the camera's position instead of orientation
  80251. */
  80252. static BILLBOARDMODE_USE_POSITION: number;
  80253. private _forward;
  80254. private _forwardInverted;
  80255. private _up;
  80256. private _right;
  80257. private _rightInverted;
  80258. private _position;
  80259. private _rotation;
  80260. private _rotationQuaternion;
  80261. protected _scaling: Vector3;
  80262. protected _isDirty: boolean;
  80263. private _transformToBoneReferal;
  80264. private _isAbsoluteSynced;
  80265. private _billboardMode;
  80266. /**
  80267. * Gets or sets the billboard mode. Default is 0.
  80268. *
  80269. * | Value | Type | Description |
  80270. * | --- | --- | --- |
  80271. * | 0 | BILLBOARDMODE_NONE | |
  80272. * | 1 | BILLBOARDMODE_X | |
  80273. * | 2 | BILLBOARDMODE_Y | |
  80274. * | 4 | BILLBOARDMODE_Z | |
  80275. * | 7 | BILLBOARDMODE_ALL | |
  80276. *
  80277. */
  80278. billboardMode: number;
  80279. private _preserveParentRotationForBillboard;
  80280. /**
  80281. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  80282. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  80283. */
  80284. preserveParentRotationForBillboard: boolean;
  80285. /**
  80286. * 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
  80287. */
  80288. scalingDeterminant: number;
  80289. private _infiniteDistance;
  80290. /**
  80291. * Gets or sets the distance of the object to max, often used by skybox
  80292. */
  80293. infiniteDistance: boolean;
  80294. /**
  80295. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  80296. * By default the system will update normals to compensate
  80297. */
  80298. ignoreNonUniformScaling: boolean;
  80299. /**
  80300. * 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
  80301. */
  80302. reIntegrateRotationIntoRotationQuaternion: boolean;
  80303. /** @hidden */
  80304. _poseMatrix: Nullable<Matrix>;
  80305. /** @hidden */
  80306. _localMatrix: Matrix;
  80307. private _usePivotMatrix;
  80308. private _absolutePosition;
  80309. private _absoluteScaling;
  80310. private _absoluteRotationQuaternion;
  80311. private _pivotMatrix;
  80312. private _pivotMatrixInverse;
  80313. protected _postMultiplyPivotMatrix: boolean;
  80314. protected _isWorldMatrixFrozen: boolean;
  80315. /** @hidden */
  80316. _indexInSceneTransformNodesArray: number;
  80317. /**
  80318. * An event triggered after the world matrix is updated
  80319. */
  80320. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  80321. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  80322. /**
  80323. * Gets a string identifying the name of the class
  80324. * @returns "TransformNode" string
  80325. */
  80326. getClassName(): string;
  80327. /**
  80328. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  80329. */
  80330. position: Vector3;
  80331. /**
  80332. * 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)).
  80333. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  80334. */
  80335. rotation: Vector3;
  80336. /**
  80337. * 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)).
  80338. */
  80339. scaling: Vector3;
  80340. /**
  80341. * 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).
  80342. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  80343. */
  80344. rotationQuaternion: Nullable<Quaternion>;
  80345. /**
  80346. * The forward direction of that transform in world space.
  80347. */
  80348. readonly forward: Vector3;
  80349. /**
  80350. * The up direction of that transform in world space.
  80351. */
  80352. readonly up: Vector3;
  80353. /**
  80354. * The right direction of that transform in world space.
  80355. */
  80356. readonly right: Vector3;
  80357. /**
  80358. * Copies the parameter passed Matrix into the mesh Pose matrix.
  80359. * @param matrix the matrix to copy the pose from
  80360. * @returns this TransformNode.
  80361. */
  80362. updatePoseMatrix(matrix: Matrix): TransformNode;
  80363. /**
  80364. * Returns the mesh Pose matrix.
  80365. * @returns the pose matrix
  80366. */
  80367. getPoseMatrix(): Matrix;
  80368. /** @hidden */
  80369. _isSynchronized(): boolean;
  80370. /** @hidden */
  80371. _initCache(): void;
  80372. /**
  80373. * Flag the transform node as dirty (Forcing it to update everything)
  80374. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  80375. * @returns this transform node
  80376. */
  80377. markAsDirty(property: string): TransformNode;
  80378. /**
  80379. * Returns the current mesh absolute position.
  80380. * Returns a Vector3.
  80381. */
  80382. readonly absolutePosition: Vector3;
  80383. /**
  80384. * Returns the current mesh absolute scaling.
  80385. * Returns a Vector3.
  80386. */
  80387. readonly absoluteScaling: Vector3;
  80388. /**
  80389. * Returns the current mesh absolute rotation.
  80390. * Returns a Quaternion.
  80391. */
  80392. readonly absoluteRotationQuaternion: Quaternion;
  80393. /**
  80394. * Sets a new matrix to apply before all other transformation
  80395. * @param matrix defines the transform matrix
  80396. * @returns the current TransformNode
  80397. */
  80398. setPreTransformMatrix(matrix: Matrix): TransformNode;
  80399. /**
  80400. * Sets a new pivot matrix to the current node
  80401. * @param matrix defines the new pivot matrix to use
  80402. * @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
  80403. * @returns the current TransformNode
  80404. */
  80405. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  80406. /**
  80407. * Returns the mesh pivot matrix.
  80408. * Default : Identity.
  80409. * @returns the matrix
  80410. */
  80411. getPivotMatrix(): Matrix;
  80412. /**
  80413. * Instantiate (when possible) or clone that node with its hierarchy
  80414. * @param newParent defines the new parent to use for the instance (or clone)
  80415. * @returns an instance (or a clone) of the current node with its hiearchy
  80416. */
  80417. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  80418. /**
  80419. * Prevents the World matrix to be computed any longer
  80420. * @param newWorldMatrix defines an optional matrix to use as world matrix
  80421. * @returns the TransformNode.
  80422. */
  80423. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  80424. /**
  80425. * Allows back the World matrix computation.
  80426. * @returns the TransformNode.
  80427. */
  80428. unfreezeWorldMatrix(): this;
  80429. /**
  80430. * True if the World matrix has been frozen.
  80431. */
  80432. readonly isWorldMatrixFrozen: boolean;
  80433. /**
  80434. * Retuns the mesh absolute position in the World.
  80435. * @returns a Vector3.
  80436. */
  80437. getAbsolutePosition(): Vector3;
  80438. /**
  80439. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  80440. * @param absolutePosition the absolute position to set
  80441. * @returns the TransformNode.
  80442. */
  80443. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80444. /**
  80445. * Sets the mesh position in its local space.
  80446. * @param vector3 the position to set in localspace
  80447. * @returns the TransformNode.
  80448. */
  80449. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  80450. /**
  80451. * Returns the mesh position in the local space from the current World matrix values.
  80452. * @returns a new Vector3.
  80453. */
  80454. getPositionExpressedInLocalSpace(): Vector3;
  80455. /**
  80456. * Translates the mesh along the passed Vector3 in its local space.
  80457. * @param vector3 the distance to translate in localspace
  80458. * @returns the TransformNode.
  80459. */
  80460. locallyTranslate(vector3: Vector3): TransformNode;
  80461. private static _lookAtVectorCache;
  80462. /**
  80463. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  80464. * @param targetPoint the position (must be in same space as current mesh) to look at
  80465. * @param yawCor optional yaw (y-axis) correction in radians
  80466. * @param pitchCor optional pitch (x-axis) correction in radians
  80467. * @param rollCor optional roll (z-axis) correction in radians
  80468. * @param space the choosen space of the target
  80469. * @returns the TransformNode.
  80470. */
  80471. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  80472. /**
  80473. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80474. * This Vector3 is expressed in the World space.
  80475. * @param localAxis axis to rotate
  80476. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80477. */
  80478. getDirection(localAxis: Vector3): Vector3;
  80479. /**
  80480. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  80481. * localAxis is expressed in the mesh local space.
  80482. * result is computed in the Wordl space from the mesh World matrix.
  80483. * @param localAxis axis to rotate
  80484. * @param result the resulting transformnode
  80485. * @returns this TransformNode.
  80486. */
  80487. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  80488. /**
  80489. * Sets this transform node rotation to the given local axis.
  80490. * @param localAxis the axis in local space
  80491. * @param yawCor optional yaw (y-axis) correction in radians
  80492. * @param pitchCor optional pitch (x-axis) correction in radians
  80493. * @param rollCor optional roll (z-axis) correction in radians
  80494. * @returns this TransformNode
  80495. */
  80496. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  80497. /**
  80498. * Sets a new pivot point to the current node
  80499. * @param point defines the new pivot point to use
  80500. * @param space defines if the point is in world or local space (local by default)
  80501. * @returns the current TransformNode
  80502. */
  80503. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  80504. /**
  80505. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  80506. * @returns the pivot point
  80507. */
  80508. getPivotPoint(): Vector3;
  80509. /**
  80510. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  80511. * @param result the vector3 to store the result
  80512. * @returns this TransformNode.
  80513. */
  80514. getPivotPointToRef(result: Vector3): TransformNode;
  80515. /**
  80516. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  80517. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  80518. */
  80519. getAbsolutePivotPoint(): Vector3;
  80520. /**
  80521. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  80522. * @param result vector3 to store the result
  80523. * @returns this TransformNode.
  80524. */
  80525. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  80526. /**
  80527. * Defines the passed node as the parent of the current node.
  80528. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  80529. * @see https://doc.babylonjs.com/how_to/parenting
  80530. * @param node the node ot set as the parent
  80531. * @returns this TransformNode.
  80532. */
  80533. setParent(node: Nullable<Node>): TransformNode;
  80534. private _nonUniformScaling;
  80535. /**
  80536. * True if the scaling property of this object is non uniform eg. (1,2,1)
  80537. */
  80538. readonly nonUniformScaling: boolean;
  80539. /** @hidden */
  80540. _updateNonUniformScalingState(value: boolean): boolean;
  80541. /**
  80542. * Attach the current TransformNode to another TransformNode associated with a bone
  80543. * @param bone Bone affecting the TransformNode
  80544. * @param affectedTransformNode TransformNode associated with the bone
  80545. * @returns this object
  80546. */
  80547. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  80548. /**
  80549. * Detach the transform node if its associated with a bone
  80550. * @returns this object
  80551. */
  80552. detachFromBone(): TransformNode;
  80553. private static _rotationAxisCache;
  80554. /**
  80555. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  80556. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80557. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80558. * The passed axis is also normalized.
  80559. * @param axis the axis to rotate around
  80560. * @param amount the amount to rotate in radians
  80561. * @param space Space to rotate in (Default: local)
  80562. * @returns the TransformNode.
  80563. */
  80564. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80565. /**
  80566. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  80567. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80568. * The passed axis is also normalized. .
  80569. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  80570. * @param point the point to rotate around
  80571. * @param axis the axis to rotate around
  80572. * @param amount the amount to rotate in radians
  80573. * @returns the TransformNode
  80574. */
  80575. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  80576. /**
  80577. * Translates the mesh along the axis vector for the passed distance in the given space.
  80578. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80579. * @param axis the axis to translate in
  80580. * @param distance the distance to translate
  80581. * @param space Space to rotate in (Default: local)
  80582. * @returns the TransformNode.
  80583. */
  80584. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80585. /**
  80586. * Adds a rotation step to the mesh current rotation.
  80587. * x, y, z are Euler angles expressed in radians.
  80588. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  80589. * This means this rotation is made in the mesh local space only.
  80590. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  80591. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  80592. * ```javascript
  80593. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  80594. * ```
  80595. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  80596. * 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.
  80597. * @param x Rotation to add
  80598. * @param y Rotation to add
  80599. * @param z Rotation to add
  80600. * @returns the TransformNode.
  80601. */
  80602. addRotation(x: number, y: number, z: number): TransformNode;
  80603. /**
  80604. * @hidden
  80605. */
  80606. protected _getEffectiveParent(): Nullable<Node>;
  80607. /**
  80608. * Computes the world matrix of the node
  80609. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80610. * @returns the world matrix
  80611. */
  80612. computeWorldMatrix(force?: boolean): Matrix;
  80613. protected _afterComputeWorldMatrix(): void;
  80614. /**
  80615. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  80616. * @param func callback function to add
  80617. *
  80618. * @returns the TransformNode.
  80619. */
  80620. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80621. /**
  80622. * Removes a registered callback function.
  80623. * @param func callback function to remove
  80624. * @returns the TransformNode.
  80625. */
  80626. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80627. /**
  80628. * Gets the position of the current mesh in camera space
  80629. * @param camera defines the camera to use
  80630. * @returns a position
  80631. */
  80632. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  80633. /**
  80634. * Returns the distance from the mesh to the active camera
  80635. * @param camera defines the camera to use
  80636. * @returns the distance
  80637. */
  80638. getDistanceToCamera(camera?: Nullable<Camera>): number;
  80639. /**
  80640. * Clone the current transform node
  80641. * @param name Name of the new clone
  80642. * @param newParent New parent for the clone
  80643. * @param doNotCloneChildren Do not clone children hierarchy
  80644. * @returns the new transform node
  80645. */
  80646. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  80647. /**
  80648. * Serializes the objects information.
  80649. * @param currentSerializationObject defines the object to serialize in
  80650. * @returns the serialized object
  80651. */
  80652. serialize(currentSerializationObject?: any): any;
  80653. /**
  80654. * Returns a new TransformNode object parsed from the source provided.
  80655. * @param parsedTransformNode is the source.
  80656. * @param scene the scne the object belongs to
  80657. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  80658. * @returns a new TransformNode object parsed from the source provided.
  80659. */
  80660. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  80661. /**
  80662. * Get all child-transformNodes of this node
  80663. * @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
  80664. * @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
  80665. * @returns an array of TransformNode
  80666. */
  80667. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  80668. /**
  80669. * Releases resources associated with this transform node.
  80670. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80671. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80672. */
  80673. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80674. /**
  80675. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  80676. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  80677. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  80678. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  80679. * @returns the current mesh
  80680. */
  80681. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  80682. private _syncAbsoluteScalingAndRotation;
  80683. }
  80684. }
  80685. declare module BABYLON {
  80686. /**
  80687. * Defines the types of pose enabled controllers that are supported
  80688. */
  80689. export enum PoseEnabledControllerType {
  80690. /**
  80691. * HTC Vive
  80692. */
  80693. VIVE = 0,
  80694. /**
  80695. * Oculus Rift
  80696. */
  80697. OCULUS = 1,
  80698. /**
  80699. * Windows mixed reality
  80700. */
  80701. WINDOWS = 2,
  80702. /**
  80703. * Samsung gear VR
  80704. */
  80705. GEAR_VR = 3,
  80706. /**
  80707. * Google Daydream
  80708. */
  80709. DAYDREAM = 4,
  80710. /**
  80711. * Generic
  80712. */
  80713. GENERIC = 5
  80714. }
  80715. /**
  80716. * Defines the MutableGamepadButton interface for the state of a gamepad button
  80717. */
  80718. export interface MutableGamepadButton {
  80719. /**
  80720. * Value of the button/trigger
  80721. */
  80722. value: number;
  80723. /**
  80724. * If the button/trigger is currently touched
  80725. */
  80726. touched: boolean;
  80727. /**
  80728. * If the button/trigger is currently pressed
  80729. */
  80730. pressed: boolean;
  80731. }
  80732. /**
  80733. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  80734. * @hidden
  80735. */
  80736. export interface ExtendedGamepadButton extends GamepadButton {
  80737. /**
  80738. * If the button/trigger is currently pressed
  80739. */
  80740. readonly pressed: boolean;
  80741. /**
  80742. * If the button/trigger is currently touched
  80743. */
  80744. readonly touched: boolean;
  80745. /**
  80746. * Value of the button/trigger
  80747. */
  80748. readonly value: number;
  80749. }
  80750. /** @hidden */
  80751. export interface _GamePadFactory {
  80752. /**
  80753. * Returns wether or not the current gamepad can be created for this type of controller.
  80754. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80755. * @returns true if it can be created, otherwise false
  80756. */
  80757. canCreate(gamepadInfo: any): boolean;
  80758. /**
  80759. * Creates a new instance of the Gamepad.
  80760. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80761. * @returns the new gamepad instance
  80762. */
  80763. create(gamepadInfo: any): Gamepad;
  80764. }
  80765. /**
  80766. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80767. */
  80768. export class PoseEnabledControllerHelper {
  80769. /** @hidden */
  80770. static _ControllerFactories: _GamePadFactory[];
  80771. /** @hidden */
  80772. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  80773. /**
  80774. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80775. * @param vrGamepad the gamepad to initialized
  80776. * @returns a vr controller of the type the gamepad identified as
  80777. */
  80778. static InitiateController(vrGamepad: any): Gamepad;
  80779. }
  80780. /**
  80781. * Defines the PoseEnabledController object that contains state of a vr capable controller
  80782. */
  80783. export class PoseEnabledController extends Gamepad implements PoseControlled {
  80784. /**
  80785. * If the controller is used in a webXR session
  80786. */
  80787. isXR: boolean;
  80788. private _deviceRoomPosition;
  80789. private _deviceRoomRotationQuaternion;
  80790. /**
  80791. * The device position in babylon space
  80792. */
  80793. devicePosition: Vector3;
  80794. /**
  80795. * The device rotation in babylon space
  80796. */
  80797. deviceRotationQuaternion: Quaternion;
  80798. /**
  80799. * The scale factor of the device in babylon space
  80800. */
  80801. deviceScaleFactor: number;
  80802. /**
  80803. * (Likely devicePosition should be used instead) The device position in its room space
  80804. */
  80805. position: Vector3;
  80806. /**
  80807. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  80808. */
  80809. rotationQuaternion: Quaternion;
  80810. /**
  80811. * The type of controller (Eg. Windows mixed reality)
  80812. */
  80813. controllerType: PoseEnabledControllerType;
  80814. protected _calculatedPosition: Vector3;
  80815. private _calculatedRotation;
  80816. /**
  80817. * The raw pose from the device
  80818. */
  80819. rawPose: DevicePose;
  80820. private _trackPosition;
  80821. private _maxRotationDistFromHeadset;
  80822. private _draggedRoomRotation;
  80823. /**
  80824. * @hidden
  80825. */
  80826. _disableTrackPosition(fixedPosition: Vector3): void;
  80827. /**
  80828. * Internal, the mesh attached to the controller
  80829. * @hidden
  80830. */
  80831. _mesh: Nullable<AbstractMesh>;
  80832. private _poseControlledCamera;
  80833. private _leftHandSystemQuaternion;
  80834. /**
  80835. * Internal, matrix used to convert room space to babylon space
  80836. * @hidden
  80837. */
  80838. _deviceToWorld: Matrix;
  80839. /**
  80840. * Node to be used when casting a ray from the controller
  80841. * @hidden
  80842. */
  80843. _pointingPoseNode: Nullable<TransformNode>;
  80844. /**
  80845. * Name of the child mesh that can be used to cast a ray from the controller
  80846. */
  80847. static readonly POINTING_POSE: string;
  80848. /**
  80849. * Creates a new PoseEnabledController from a gamepad
  80850. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  80851. */
  80852. constructor(browserGamepad: any);
  80853. private _workingMatrix;
  80854. /**
  80855. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  80856. */
  80857. update(): void;
  80858. /**
  80859. * Updates only the pose device and mesh without doing any button event checking
  80860. */
  80861. protected _updatePoseAndMesh(): void;
  80862. /**
  80863. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  80864. * @param poseData raw pose fromthe device
  80865. */
  80866. updateFromDevice(poseData: DevicePose): void;
  80867. /**
  80868. * @hidden
  80869. */
  80870. _meshAttachedObservable: Observable<AbstractMesh>;
  80871. /**
  80872. * Attaches a mesh to the controller
  80873. * @param mesh the mesh to be attached
  80874. */
  80875. attachToMesh(mesh: AbstractMesh): void;
  80876. /**
  80877. * Attaches the controllers mesh to a camera
  80878. * @param camera the camera the mesh should be attached to
  80879. */
  80880. attachToPoseControlledCamera(camera: TargetCamera): void;
  80881. /**
  80882. * Disposes of the controller
  80883. */
  80884. dispose(): void;
  80885. /**
  80886. * The mesh that is attached to the controller
  80887. */
  80888. readonly mesh: Nullable<AbstractMesh>;
  80889. /**
  80890. * Gets the ray of the controller in the direction the controller is pointing
  80891. * @param length the length the resulting ray should be
  80892. * @returns a ray in the direction the controller is pointing
  80893. */
  80894. getForwardRay(length?: number): Ray;
  80895. }
  80896. }
  80897. declare module BABYLON {
  80898. /**
  80899. * Defines the WebVRController object that represents controllers tracked in 3D space
  80900. */
  80901. export abstract class WebVRController extends PoseEnabledController {
  80902. /**
  80903. * Internal, the default controller model for the controller
  80904. */
  80905. protected _defaultModel: Nullable<AbstractMesh>;
  80906. /**
  80907. * Fired when the trigger state has changed
  80908. */
  80909. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  80910. /**
  80911. * Fired when the main button state has changed
  80912. */
  80913. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80914. /**
  80915. * Fired when the secondary button state has changed
  80916. */
  80917. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80918. /**
  80919. * Fired when the pad state has changed
  80920. */
  80921. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  80922. /**
  80923. * Fired when controllers stick values have changed
  80924. */
  80925. onPadValuesChangedObservable: Observable<StickValues>;
  80926. /**
  80927. * Array of button availible on the controller
  80928. */
  80929. protected _buttons: Array<MutableGamepadButton>;
  80930. private _onButtonStateChange;
  80931. /**
  80932. * Fired when a controller button's state has changed
  80933. * @param callback the callback containing the button that was modified
  80934. */
  80935. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  80936. /**
  80937. * X and Y axis corresponding to the controllers joystick
  80938. */
  80939. pad: StickValues;
  80940. /**
  80941. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  80942. */
  80943. hand: string;
  80944. /**
  80945. * The default controller model for the controller
  80946. */
  80947. readonly defaultModel: Nullable<AbstractMesh>;
  80948. /**
  80949. * Creates a new WebVRController from a gamepad
  80950. * @param vrGamepad the gamepad that the WebVRController should be created from
  80951. */
  80952. constructor(vrGamepad: any);
  80953. /**
  80954. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  80955. */
  80956. update(): void;
  80957. /**
  80958. * Function to be called when a button is modified
  80959. */
  80960. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  80961. /**
  80962. * Loads a mesh and attaches it to the controller
  80963. * @param scene the scene the mesh should be added to
  80964. * @param meshLoaded callback for when the mesh has been loaded
  80965. */
  80966. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  80967. private _setButtonValue;
  80968. private _changes;
  80969. private _checkChanges;
  80970. /**
  80971. * Disposes of th webVRCOntroller
  80972. */
  80973. dispose(): void;
  80974. }
  80975. }
  80976. declare module BABYLON {
  80977. /**
  80978. * The HemisphericLight simulates the ambient environment light,
  80979. * so the passed direction is the light reflection direction, not the incoming direction.
  80980. */
  80981. export class HemisphericLight extends Light {
  80982. /**
  80983. * The groundColor is the light in the opposite direction to the one specified during creation.
  80984. * 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.
  80985. */
  80986. groundColor: Color3;
  80987. /**
  80988. * The light reflection direction, not the incoming direction.
  80989. */
  80990. direction: Vector3;
  80991. /**
  80992. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  80993. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  80994. * The HemisphericLight can't cast shadows.
  80995. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80996. * @param name The friendly name of the light
  80997. * @param direction The direction of the light reflection
  80998. * @param scene The scene the light belongs to
  80999. */
  81000. constructor(name: string, direction: Vector3, scene: Scene);
  81001. protected _buildUniformLayout(): void;
  81002. /**
  81003. * Returns the string "HemisphericLight".
  81004. * @return The class name
  81005. */
  81006. getClassName(): string;
  81007. /**
  81008. * Sets the HemisphericLight direction towards the passed target (Vector3).
  81009. * Returns the updated direction.
  81010. * @param target The target the direction should point to
  81011. * @return The computed direction
  81012. */
  81013. setDirectionToTarget(target: Vector3): Vector3;
  81014. /**
  81015. * Returns the shadow generator associated to the light.
  81016. * @returns Always null for hemispheric lights because it does not support shadows.
  81017. */
  81018. getShadowGenerator(): Nullable<IShadowGenerator>;
  81019. /**
  81020. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  81021. * @param effect The effect to update
  81022. * @param lightIndex The index of the light in the effect to update
  81023. * @returns The hemispheric light
  81024. */
  81025. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  81026. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  81027. /**
  81028. * Computes the world matrix of the node
  81029. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81030. * @param useWasUpdatedFlag defines a reserved property
  81031. * @returns the world matrix
  81032. */
  81033. computeWorldMatrix(): Matrix;
  81034. /**
  81035. * Returns the integer 3.
  81036. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  81037. */
  81038. getTypeID(): number;
  81039. /**
  81040. * Prepares the list of defines specific to the light type.
  81041. * @param defines the list of defines
  81042. * @param lightIndex defines the index of the light for the effect
  81043. */
  81044. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  81045. }
  81046. }
  81047. declare module BABYLON {
  81048. /** @hidden */
  81049. export var vrMultiviewToSingleviewPixelShader: {
  81050. name: string;
  81051. shader: string;
  81052. };
  81053. }
  81054. declare module BABYLON {
  81055. /**
  81056. * Renders to multiple views with a single draw call
  81057. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  81058. */
  81059. export class MultiviewRenderTarget extends RenderTargetTexture {
  81060. /**
  81061. * Creates a multiview render target
  81062. * @param scene scene used with the render target
  81063. * @param size the size of the render target (used for each view)
  81064. */
  81065. constructor(scene: Scene, size?: number | {
  81066. width: number;
  81067. height: number;
  81068. } | {
  81069. ratio: number;
  81070. });
  81071. /**
  81072. * @hidden
  81073. * @param faceIndex the face index, if its a cube texture
  81074. */
  81075. _bindFrameBuffer(faceIndex?: number): void;
  81076. /**
  81077. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  81078. * @returns the view count
  81079. */
  81080. getViewCount(): number;
  81081. }
  81082. }
  81083. declare module BABYLON {
  81084. /**
  81085. * Represents a camera frustum
  81086. */
  81087. export class Frustum {
  81088. /**
  81089. * Gets the planes representing the frustum
  81090. * @param transform matrix to be applied to the returned planes
  81091. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  81092. */
  81093. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  81094. /**
  81095. * Gets the near frustum plane transformed by the transform matrix
  81096. * @param transform transformation matrix to be applied to the resulting frustum plane
  81097. * @param frustumPlane the resuling frustum plane
  81098. */
  81099. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81100. /**
  81101. * Gets the far frustum plane transformed by the transform matrix
  81102. * @param transform transformation matrix to be applied to the resulting frustum plane
  81103. * @param frustumPlane the resuling frustum plane
  81104. */
  81105. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81106. /**
  81107. * Gets the left frustum plane transformed by the transform matrix
  81108. * @param transform transformation matrix to be applied to the resulting frustum plane
  81109. * @param frustumPlane the resuling frustum plane
  81110. */
  81111. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81112. /**
  81113. * Gets the right frustum plane transformed by the transform matrix
  81114. * @param transform transformation matrix to be applied to the resulting frustum plane
  81115. * @param frustumPlane the resuling frustum plane
  81116. */
  81117. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81118. /**
  81119. * Gets the top frustum plane transformed by the transform matrix
  81120. * @param transform transformation matrix to be applied to the resulting frustum plane
  81121. * @param frustumPlane the resuling frustum plane
  81122. */
  81123. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81124. /**
  81125. * Gets the bottom frustum plane transformed by the transform matrix
  81126. * @param transform transformation matrix to be applied to the resulting frustum plane
  81127. * @param frustumPlane the resuling frustum plane
  81128. */
  81129. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81130. /**
  81131. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  81132. * @param transform transformation matrix to be applied to the resulting frustum planes
  81133. * @param frustumPlanes the resuling frustum planes
  81134. */
  81135. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  81136. }
  81137. }
  81138. declare module BABYLON {
  81139. interface Engine {
  81140. /**
  81141. * Creates a new multiview render target
  81142. * @param width defines the width of the texture
  81143. * @param height defines the height of the texture
  81144. * @returns the created multiview texture
  81145. */
  81146. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  81147. /**
  81148. * Binds a multiview framebuffer to be drawn to
  81149. * @param multiviewTexture texture to bind
  81150. */
  81151. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  81152. }
  81153. interface Camera {
  81154. /**
  81155. * @hidden
  81156. * 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)
  81157. */
  81158. _useMultiviewToSingleView: boolean;
  81159. /**
  81160. * @hidden
  81161. * 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)
  81162. */
  81163. _multiviewTexture: Nullable<RenderTargetTexture>;
  81164. /**
  81165. * @hidden
  81166. * ensures the multiview texture of the camera exists and has the specified width/height
  81167. * @param width height to set on the multiview texture
  81168. * @param height width to set on the multiview texture
  81169. */
  81170. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  81171. }
  81172. interface Scene {
  81173. /** @hidden */
  81174. _transformMatrixR: Matrix;
  81175. /** @hidden */
  81176. _multiviewSceneUbo: Nullable<UniformBuffer>;
  81177. /** @hidden */
  81178. _createMultiviewUbo(): void;
  81179. /** @hidden */
  81180. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  81181. /** @hidden */
  81182. _renderMultiviewToSingleView(camera: Camera): void;
  81183. }
  81184. }
  81185. declare module BABYLON {
  81186. /**
  81187. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  81188. * This will not be used for webXR as it supports displaying texture arrays directly
  81189. */
  81190. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  81191. /**
  81192. * Initializes a VRMultiviewToSingleview
  81193. * @param name name of the post process
  81194. * @param camera camera to be applied to
  81195. * @param scaleFactor scaling factor to the size of the output texture
  81196. */
  81197. constructor(name: string, camera: Camera, scaleFactor: number);
  81198. }
  81199. }
  81200. declare module BABYLON {
  81201. interface Engine {
  81202. /** @hidden */
  81203. _vrDisplay: any;
  81204. /** @hidden */
  81205. _vrSupported: boolean;
  81206. /** @hidden */
  81207. _oldSize: Size;
  81208. /** @hidden */
  81209. _oldHardwareScaleFactor: number;
  81210. /** @hidden */
  81211. _vrExclusivePointerMode: boolean;
  81212. /** @hidden */
  81213. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  81214. /** @hidden */
  81215. _onVRDisplayPointerRestricted: () => void;
  81216. /** @hidden */
  81217. _onVRDisplayPointerUnrestricted: () => void;
  81218. /** @hidden */
  81219. _onVrDisplayConnect: Nullable<(display: any) => void>;
  81220. /** @hidden */
  81221. _onVrDisplayDisconnect: Nullable<() => void>;
  81222. /** @hidden */
  81223. _onVrDisplayPresentChange: Nullable<() => void>;
  81224. /**
  81225. * Observable signaled when VR display mode changes
  81226. */
  81227. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  81228. /**
  81229. * Observable signaled when VR request present is complete
  81230. */
  81231. onVRRequestPresentComplete: Observable<boolean>;
  81232. /**
  81233. * Observable signaled when VR request present starts
  81234. */
  81235. onVRRequestPresentStart: Observable<Engine>;
  81236. /**
  81237. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  81238. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  81239. */
  81240. isInVRExclusivePointerMode: boolean;
  81241. /**
  81242. * Gets a boolean indicating if a webVR device was detected
  81243. * @returns true if a webVR device was detected
  81244. */
  81245. isVRDevicePresent(): boolean;
  81246. /**
  81247. * Gets the current webVR device
  81248. * @returns the current webVR device (or null)
  81249. */
  81250. getVRDevice(): any;
  81251. /**
  81252. * Initializes a webVR display and starts listening to display change events
  81253. * The onVRDisplayChangedObservable will be notified upon these changes
  81254. * @returns A promise containing a VRDisplay and if vr is supported
  81255. */
  81256. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  81257. /** @hidden */
  81258. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  81259. /**
  81260. * Call this function to switch to webVR mode
  81261. * Will do nothing if webVR is not supported or if there is no webVR device
  81262. * @see http://doc.babylonjs.com/how_to/webvr_camera
  81263. */
  81264. enableVR(): void;
  81265. /** @hidden */
  81266. _onVRFullScreenTriggered(): void;
  81267. }
  81268. }
  81269. declare module BABYLON {
  81270. /**
  81271. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  81272. * IMPORTANT!! The data is right-hand data.
  81273. * @export
  81274. * @interface DevicePose
  81275. */
  81276. export interface DevicePose {
  81277. /**
  81278. * The position of the device, values in array are [x,y,z].
  81279. */
  81280. readonly position: Nullable<Float32Array>;
  81281. /**
  81282. * The linearVelocity of the device, values in array are [x,y,z].
  81283. */
  81284. readonly linearVelocity: Nullable<Float32Array>;
  81285. /**
  81286. * The linearAcceleration of the device, values in array are [x,y,z].
  81287. */
  81288. readonly linearAcceleration: Nullable<Float32Array>;
  81289. /**
  81290. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  81291. */
  81292. readonly orientation: Nullable<Float32Array>;
  81293. /**
  81294. * The angularVelocity of the device, values in array are [x,y,z].
  81295. */
  81296. readonly angularVelocity: Nullable<Float32Array>;
  81297. /**
  81298. * The angularAcceleration of the device, values in array are [x,y,z].
  81299. */
  81300. readonly angularAcceleration: Nullable<Float32Array>;
  81301. }
  81302. /**
  81303. * Interface representing a pose controlled object in Babylon.
  81304. * A pose controlled object has both regular pose values as well as pose values
  81305. * from an external device such as a VR head mounted display
  81306. */
  81307. export interface PoseControlled {
  81308. /**
  81309. * The position of the object in babylon space.
  81310. */
  81311. position: Vector3;
  81312. /**
  81313. * The rotation quaternion of the object in babylon space.
  81314. */
  81315. rotationQuaternion: Quaternion;
  81316. /**
  81317. * The position of the device in babylon space.
  81318. */
  81319. devicePosition?: Vector3;
  81320. /**
  81321. * The rotation quaternion of the device in babylon space.
  81322. */
  81323. deviceRotationQuaternion: Quaternion;
  81324. /**
  81325. * The raw pose coming from the device.
  81326. */
  81327. rawPose: Nullable<DevicePose>;
  81328. /**
  81329. * The scale of the device to be used when translating from device space to babylon space.
  81330. */
  81331. deviceScaleFactor: number;
  81332. /**
  81333. * Updates the poseControlled values based on the input device pose.
  81334. * @param poseData the pose data to update the object with
  81335. */
  81336. updateFromDevice(poseData: DevicePose): void;
  81337. }
  81338. /**
  81339. * Set of options to customize the webVRCamera
  81340. */
  81341. export interface WebVROptions {
  81342. /**
  81343. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  81344. */
  81345. trackPosition?: boolean;
  81346. /**
  81347. * Sets the scale of the vrDevice in babylon space. (default: 1)
  81348. */
  81349. positionScale?: number;
  81350. /**
  81351. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  81352. */
  81353. displayName?: string;
  81354. /**
  81355. * Should the native controller meshes be initialized. (default: true)
  81356. */
  81357. controllerMeshes?: boolean;
  81358. /**
  81359. * Creating a default HemiLight only on controllers. (default: true)
  81360. */
  81361. defaultLightingOnControllers?: boolean;
  81362. /**
  81363. * If you don't want to use the default VR button of the helper. (default: false)
  81364. */
  81365. useCustomVRButton?: boolean;
  81366. /**
  81367. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  81368. */
  81369. customVRButton?: HTMLButtonElement;
  81370. /**
  81371. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  81372. */
  81373. rayLength?: number;
  81374. /**
  81375. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  81376. */
  81377. defaultHeight?: number;
  81378. /**
  81379. * If multiview should be used if availible (default: false)
  81380. */
  81381. useMultiview?: boolean;
  81382. }
  81383. /**
  81384. * This represents a WebVR camera.
  81385. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  81386. * @example http://doc.babylonjs.com/how_to/webvr_camera
  81387. */
  81388. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  81389. private webVROptions;
  81390. /**
  81391. * @hidden
  81392. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  81393. */
  81394. _vrDevice: any;
  81395. /**
  81396. * The rawPose of the vrDevice.
  81397. */
  81398. rawPose: Nullable<DevicePose>;
  81399. private _onVREnabled;
  81400. private _specsVersion;
  81401. private _attached;
  81402. private _frameData;
  81403. protected _descendants: Array<Node>;
  81404. private _deviceRoomPosition;
  81405. /** @hidden */
  81406. _deviceRoomRotationQuaternion: Quaternion;
  81407. private _standingMatrix;
  81408. /**
  81409. * Represents device position in babylon space.
  81410. */
  81411. devicePosition: Vector3;
  81412. /**
  81413. * Represents device rotation in babylon space.
  81414. */
  81415. deviceRotationQuaternion: Quaternion;
  81416. /**
  81417. * The scale of the device to be used when translating from device space to babylon space.
  81418. */
  81419. deviceScaleFactor: number;
  81420. private _deviceToWorld;
  81421. private _worldToDevice;
  81422. /**
  81423. * References to the webVR controllers for the vrDevice.
  81424. */
  81425. controllers: Array<WebVRController>;
  81426. /**
  81427. * Emits an event when a controller is attached.
  81428. */
  81429. onControllersAttachedObservable: Observable<WebVRController[]>;
  81430. /**
  81431. * Emits an event when a controller's mesh has been loaded;
  81432. */
  81433. onControllerMeshLoadedObservable: Observable<WebVRController>;
  81434. /**
  81435. * Emits an event when the HMD's pose has been updated.
  81436. */
  81437. onPoseUpdatedFromDeviceObservable: Observable<any>;
  81438. private _poseSet;
  81439. /**
  81440. * If the rig cameras be used as parent instead of this camera.
  81441. */
  81442. rigParenting: boolean;
  81443. private _lightOnControllers;
  81444. private _defaultHeight?;
  81445. /**
  81446. * Instantiates a WebVRFreeCamera.
  81447. * @param name The name of the WebVRFreeCamera
  81448. * @param position The starting anchor position for the camera
  81449. * @param scene The scene the camera belongs to
  81450. * @param webVROptions a set of customizable options for the webVRCamera
  81451. */
  81452. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  81453. /**
  81454. * Gets the device distance from the ground in meters.
  81455. * @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.
  81456. */
  81457. deviceDistanceToRoomGround(): number;
  81458. /**
  81459. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81460. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  81461. */
  81462. useStandingMatrix(callback?: (bool: boolean) => void): void;
  81463. /**
  81464. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81465. * @returns A promise with a boolean set to if the standing matrix is supported.
  81466. */
  81467. useStandingMatrixAsync(): Promise<boolean>;
  81468. /**
  81469. * Disposes the camera
  81470. */
  81471. dispose(): void;
  81472. /**
  81473. * Gets a vrController by name.
  81474. * @param name The name of the controller to retreive
  81475. * @returns the controller matching the name specified or null if not found
  81476. */
  81477. getControllerByName(name: string): Nullable<WebVRController>;
  81478. private _leftController;
  81479. /**
  81480. * The controller corresponding to the users left hand.
  81481. */
  81482. readonly leftController: Nullable<WebVRController>;
  81483. private _rightController;
  81484. /**
  81485. * The controller corresponding to the users right hand.
  81486. */
  81487. readonly rightController: Nullable<WebVRController>;
  81488. /**
  81489. * Casts a ray forward from the vrCamera's gaze.
  81490. * @param length Length of the ray (default: 100)
  81491. * @returns the ray corresponding to the gaze
  81492. */
  81493. getForwardRay(length?: number): Ray;
  81494. /**
  81495. * @hidden
  81496. * Updates the camera based on device's frame data
  81497. */
  81498. _checkInputs(): void;
  81499. /**
  81500. * Updates the poseControlled values based on the input device pose.
  81501. * @param poseData Pose coming from the device
  81502. */
  81503. updateFromDevice(poseData: DevicePose): void;
  81504. private _htmlElementAttached;
  81505. private _detachIfAttached;
  81506. /**
  81507. * WebVR's attach control will start broadcasting frames to the device.
  81508. * Note that in certain browsers (chrome for example) this function must be called
  81509. * within a user-interaction callback. Example:
  81510. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  81511. *
  81512. * @param element html element to attach the vrDevice to
  81513. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  81514. */
  81515. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81516. /**
  81517. * Detaches the camera from the html element and disables VR
  81518. *
  81519. * @param element html element to detach from
  81520. */
  81521. detachControl(element: HTMLElement): void;
  81522. /**
  81523. * @returns the name of this class
  81524. */
  81525. getClassName(): string;
  81526. /**
  81527. * Calls resetPose on the vrDisplay
  81528. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  81529. */
  81530. resetToCurrentRotation(): void;
  81531. /**
  81532. * @hidden
  81533. * Updates the rig cameras (left and right eye)
  81534. */
  81535. _updateRigCameras(): void;
  81536. private _workingVector;
  81537. private _oneVector;
  81538. private _workingMatrix;
  81539. private updateCacheCalled;
  81540. private _correctPositionIfNotTrackPosition;
  81541. /**
  81542. * @hidden
  81543. * Updates the cached values of the camera
  81544. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  81545. */
  81546. _updateCache(ignoreParentClass?: boolean): void;
  81547. /**
  81548. * @hidden
  81549. * Get current device position in babylon world
  81550. */
  81551. _computeDevicePosition(): void;
  81552. /**
  81553. * Updates the current device position and rotation in the babylon world
  81554. */
  81555. update(): void;
  81556. /**
  81557. * @hidden
  81558. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  81559. * @returns an identity matrix
  81560. */
  81561. _getViewMatrix(): Matrix;
  81562. private _tmpMatrix;
  81563. /**
  81564. * This function is called by the two RIG cameras.
  81565. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  81566. * @hidden
  81567. */
  81568. _getWebVRViewMatrix(): Matrix;
  81569. /** @hidden */
  81570. _getWebVRProjectionMatrix(): Matrix;
  81571. private _onGamepadConnectedObserver;
  81572. private _onGamepadDisconnectedObserver;
  81573. private _updateCacheWhenTrackingDisabledObserver;
  81574. /**
  81575. * Initializes the controllers and their meshes
  81576. */
  81577. initControllers(): void;
  81578. }
  81579. }
  81580. declare module BABYLON {
  81581. /**
  81582. * Size options for a post process
  81583. */
  81584. export type PostProcessOptions = {
  81585. width: number;
  81586. height: number;
  81587. };
  81588. /**
  81589. * PostProcess can be used to apply a shader to a texture after it has been rendered
  81590. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81591. */
  81592. export class PostProcess {
  81593. /** Name of the PostProcess. */
  81594. name: string;
  81595. /**
  81596. * Gets or sets the unique id of the post process
  81597. */
  81598. uniqueId: number;
  81599. /**
  81600. * Width of the texture to apply the post process on
  81601. */
  81602. width: number;
  81603. /**
  81604. * Height of the texture to apply the post process on
  81605. */
  81606. height: number;
  81607. /**
  81608. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  81609. * @hidden
  81610. */
  81611. _outputTexture: Nullable<InternalTexture>;
  81612. /**
  81613. * Sampling mode used by the shader
  81614. * See https://doc.babylonjs.com/classes/3.1/texture
  81615. */
  81616. renderTargetSamplingMode: number;
  81617. /**
  81618. * Clear color to use when screen clearing
  81619. */
  81620. clearColor: Color4;
  81621. /**
  81622. * If the buffer needs to be cleared before applying the post process. (default: true)
  81623. * Should be set to false if shader will overwrite all previous pixels.
  81624. */
  81625. autoClear: boolean;
  81626. /**
  81627. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  81628. */
  81629. alphaMode: number;
  81630. /**
  81631. * Sets the setAlphaBlendConstants of the babylon engine
  81632. */
  81633. alphaConstants: Color4;
  81634. /**
  81635. * Animations to be used for the post processing
  81636. */
  81637. animations: Animation[];
  81638. /**
  81639. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  81640. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  81641. */
  81642. enablePixelPerfectMode: boolean;
  81643. /**
  81644. * Force the postprocess to be applied without taking in account viewport
  81645. */
  81646. forceFullscreenViewport: boolean;
  81647. /**
  81648. * List of inspectable custom properties (used by the Inspector)
  81649. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81650. */
  81651. inspectableCustomProperties: IInspectable[];
  81652. /**
  81653. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  81654. *
  81655. * | Value | Type | Description |
  81656. * | ----- | ----------------------------------- | ----------- |
  81657. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  81658. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  81659. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  81660. *
  81661. */
  81662. scaleMode: number;
  81663. /**
  81664. * Force textures to be a power of two (default: false)
  81665. */
  81666. alwaysForcePOT: boolean;
  81667. private _samples;
  81668. /**
  81669. * Number of sample textures (default: 1)
  81670. */
  81671. samples: number;
  81672. /**
  81673. * Modify the scale of the post process to be the same as the viewport (default: false)
  81674. */
  81675. adaptScaleToCurrentViewport: boolean;
  81676. private _camera;
  81677. private _scene;
  81678. private _engine;
  81679. private _options;
  81680. private _reusable;
  81681. private _textureType;
  81682. /**
  81683. * Smart array of input and output textures for the post process.
  81684. * @hidden
  81685. */
  81686. _textures: SmartArray<InternalTexture>;
  81687. /**
  81688. * The index in _textures that corresponds to the output texture.
  81689. * @hidden
  81690. */
  81691. _currentRenderTextureInd: number;
  81692. private _effect;
  81693. private _samplers;
  81694. private _fragmentUrl;
  81695. private _vertexUrl;
  81696. private _parameters;
  81697. private _scaleRatio;
  81698. protected _indexParameters: any;
  81699. private _shareOutputWithPostProcess;
  81700. private _texelSize;
  81701. private _forcedOutputTexture;
  81702. /**
  81703. * Returns the fragment url or shader name used in the post process.
  81704. * @returns the fragment url or name in the shader store.
  81705. */
  81706. getEffectName(): string;
  81707. /**
  81708. * An event triggered when the postprocess is activated.
  81709. */
  81710. onActivateObservable: Observable<Camera>;
  81711. private _onActivateObserver;
  81712. /**
  81713. * A function that is added to the onActivateObservable
  81714. */
  81715. onActivate: Nullable<(camera: Camera) => void>;
  81716. /**
  81717. * An event triggered when the postprocess changes its size.
  81718. */
  81719. onSizeChangedObservable: Observable<PostProcess>;
  81720. private _onSizeChangedObserver;
  81721. /**
  81722. * A function that is added to the onSizeChangedObservable
  81723. */
  81724. onSizeChanged: (postProcess: PostProcess) => void;
  81725. /**
  81726. * An event triggered when the postprocess applies its effect.
  81727. */
  81728. onApplyObservable: Observable<Effect>;
  81729. private _onApplyObserver;
  81730. /**
  81731. * A function that is added to the onApplyObservable
  81732. */
  81733. onApply: (effect: Effect) => void;
  81734. /**
  81735. * An event triggered before rendering the postprocess
  81736. */
  81737. onBeforeRenderObservable: Observable<Effect>;
  81738. private _onBeforeRenderObserver;
  81739. /**
  81740. * A function that is added to the onBeforeRenderObservable
  81741. */
  81742. onBeforeRender: (effect: Effect) => void;
  81743. /**
  81744. * An event triggered after rendering the postprocess
  81745. */
  81746. onAfterRenderObservable: Observable<Effect>;
  81747. private _onAfterRenderObserver;
  81748. /**
  81749. * A function that is added to the onAfterRenderObservable
  81750. */
  81751. onAfterRender: (efect: Effect) => void;
  81752. /**
  81753. * 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
  81754. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  81755. */
  81756. inputTexture: InternalTexture;
  81757. /**
  81758. * Gets the camera which post process is applied to.
  81759. * @returns The camera the post process is applied to.
  81760. */
  81761. getCamera(): Camera;
  81762. /**
  81763. * Gets the texel size of the postprocess.
  81764. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  81765. */
  81766. readonly texelSize: Vector2;
  81767. /**
  81768. * Creates a new instance PostProcess
  81769. * @param name The name of the PostProcess.
  81770. * @param fragmentUrl The url of the fragment shader to be used.
  81771. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  81772. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  81773. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81774. * @param camera The camera to apply the render pass to.
  81775. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81776. * @param engine The engine which the post process will be applied. (default: current engine)
  81777. * @param reusable If the post process can be reused on the same frame. (default: false)
  81778. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  81779. * @param textureType Type of textures used when performing the post process. (default: 0)
  81780. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  81781. * @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
  81782. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  81783. */
  81784. constructor(
  81785. /** Name of the PostProcess. */
  81786. 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);
  81787. /**
  81788. * Gets a string idenfifying the name of the class
  81789. * @returns "PostProcess" string
  81790. */
  81791. getClassName(): string;
  81792. /**
  81793. * Gets the engine which this post process belongs to.
  81794. * @returns The engine the post process was enabled with.
  81795. */
  81796. getEngine(): Engine;
  81797. /**
  81798. * The effect that is created when initializing the post process.
  81799. * @returns The created effect corresponding the the postprocess.
  81800. */
  81801. getEffect(): Effect;
  81802. /**
  81803. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  81804. * @param postProcess The post process to share the output with.
  81805. * @returns This post process.
  81806. */
  81807. shareOutputWith(postProcess: PostProcess): PostProcess;
  81808. /**
  81809. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  81810. * This should be called if the post process that shares output with this post process is disabled/disposed.
  81811. */
  81812. useOwnOutput(): void;
  81813. /**
  81814. * Updates the effect with the current post process compile time values and recompiles the shader.
  81815. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81816. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81817. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81818. * @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
  81819. * @param onCompiled Called when the shader has been compiled.
  81820. * @param onError Called if there is an error when compiling a shader.
  81821. */
  81822. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81823. /**
  81824. * The post process is reusable if it can be used multiple times within one frame.
  81825. * @returns If the post process is reusable
  81826. */
  81827. isReusable(): boolean;
  81828. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  81829. markTextureDirty(): void;
  81830. /**
  81831. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  81832. * 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.
  81833. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  81834. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  81835. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  81836. * @returns The target texture that was bound to be written to.
  81837. */
  81838. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  81839. /**
  81840. * If the post process is supported.
  81841. */
  81842. readonly isSupported: boolean;
  81843. /**
  81844. * The aspect ratio of the output texture.
  81845. */
  81846. readonly aspectRatio: number;
  81847. /**
  81848. * Get a value indicating if the post-process is ready to be used
  81849. * @returns true if the post-process is ready (shader is compiled)
  81850. */
  81851. isReady(): boolean;
  81852. /**
  81853. * Binds all textures and uniforms to the shader, this will be run on every pass.
  81854. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  81855. */
  81856. apply(): Nullable<Effect>;
  81857. private _disposeTextures;
  81858. /**
  81859. * Disposes the post process.
  81860. * @param camera The camera to dispose the post process on.
  81861. */
  81862. dispose(camera?: Camera): void;
  81863. }
  81864. }
  81865. declare module BABYLON {
  81866. /** @hidden */
  81867. export var kernelBlurVaryingDeclaration: {
  81868. name: string;
  81869. shader: string;
  81870. };
  81871. }
  81872. declare module BABYLON {
  81873. /** @hidden */
  81874. export var kernelBlurFragment: {
  81875. name: string;
  81876. shader: string;
  81877. };
  81878. }
  81879. declare module BABYLON {
  81880. /** @hidden */
  81881. export var kernelBlurFragment2: {
  81882. name: string;
  81883. shader: string;
  81884. };
  81885. }
  81886. declare module BABYLON {
  81887. /** @hidden */
  81888. export var kernelBlurPixelShader: {
  81889. name: string;
  81890. shader: string;
  81891. };
  81892. }
  81893. declare module BABYLON {
  81894. /** @hidden */
  81895. export var kernelBlurVertex: {
  81896. name: string;
  81897. shader: string;
  81898. };
  81899. }
  81900. declare module BABYLON {
  81901. /** @hidden */
  81902. export var kernelBlurVertexShader: {
  81903. name: string;
  81904. shader: string;
  81905. };
  81906. }
  81907. declare module BABYLON {
  81908. /**
  81909. * The Blur Post Process which blurs an image based on a kernel and direction.
  81910. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  81911. */
  81912. export class BlurPostProcess extends PostProcess {
  81913. /** The direction in which to blur the image. */
  81914. direction: Vector2;
  81915. private blockCompilation;
  81916. protected _kernel: number;
  81917. protected _idealKernel: number;
  81918. protected _packedFloat: boolean;
  81919. private _staticDefines;
  81920. /**
  81921. * Sets the length in pixels of the blur sample region
  81922. */
  81923. /**
  81924. * Gets the length in pixels of the blur sample region
  81925. */
  81926. kernel: number;
  81927. /**
  81928. * Sets wether or not the blur needs to unpack/repack floats
  81929. */
  81930. /**
  81931. * Gets wether or not the blur is unpacking/repacking floats
  81932. */
  81933. packedFloat: boolean;
  81934. /**
  81935. * Creates a new instance BlurPostProcess
  81936. * @param name The name of the effect.
  81937. * @param direction The direction in which to blur the image.
  81938. * @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.
  81939. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81940. * @param camera The camera to apply the render pass to.
  81941. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81942. * @param engine The engine which the post process will be applied. (default: current engine)
  81943. * @param reusable If the post process can be reused on the same frame. (default: false)
  81944. * @param textureType Type of textures used when performing the post process. (default: 0)
  81945. * @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)
  81946. */
  81947. constructor(name: string,
  81948. /** The direction in which to blur the image. */
  81949. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  81950. /**
  81951. * Updates the effect with the current post process compile time values and recompiles the shader.
  81952. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81953. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81954. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81955. * @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
  81956. * @param onCompiled Called when the shader has been compiled.
  81957. * @param onError Called if there is an error when compiling a shader.
  81958. */
  81959. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81960. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81961. /**
  81962. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  81963. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  81964. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  81965. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  81966. * The gaps between physical kernels are compensated for in the weighting of the samples
  81967. * @param idealKernel Ideal blur kernel.
  81968. * @return Nearest best kernel.
  81969. */
  81970. protected _nearestBestKernel(idealKernel: number): number;
  81971. /**
  81972. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  81973. * @param x The point on the Gaussian distribution to sample.
  81974. * @return the value of the Gaussian function at x.
  81975. */
  81976. protected _gaussianWeight(x: number): number;
  81977. /**
  81978. * Generates a string that can be used as a floating point number in GLSL.
  81979. * @param x Value to print.
  81980. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  81981. * @return GLSL float string.
  81982. */
  81983. protected _glslFloat(x: number, decimalFigures?: number): string;
  81984. }
  81985. }
  81986. declare module BABYLON {
  81987. /**
  81988. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81989. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81990. * You can then easily use it as a reflectionTexture on a flat surface.
  81991. * In case the surface is not a plane, please consider relying on reflection probes.
  81992. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81993. */
  81994. export class MirrorTexture extends RenderTargetTexture {
  81995. private scene;
  81996. /**
  81997. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  81998. * 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.
  81999. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82000. */
  82001. mirrorPlane: Plane;
  82002. /**
  82003. * Define the blur ratio used to blur the reflection if needed.
  82004. */
  82005. blurRatio: number;
  82006. /**
  82007. * Define the adaptive blur kernel used to blur the reflection if needed.
  82008. * This will autocompute the closest best match for the `blurKernel`
  82009. */
  82010. adaptiveBlurKernel: number;
  82011. /**
  82012. * Define the blur kernel used to blur the reflection if needed.
  82013. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82014. */
  82015. blurKernel: number;
  82016. /**
  82017. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  82018. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82019. */
  82020. blurKernelX: number;
  82021. /**
  82022. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  82023. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82024. */
  82025. blurKernelY: number;
  82026. private _autoComputeBlurKernel;
  82027. protected _onRatioRescale(): void;
  82028. private _updateGammaSpace;
  82029. private _imageProcessingConfigChangeObserver;
  82030. private _transformMatrix;
  82031. private _mirrorMatrix;
  82032. private _savedViewMatrix;
  82033. private _blurX;
  82034. private _blurY;
  82035. private _adaptiveBlurKernel;
  82036. private _blurKernelX;
  82037. private _blurKernelY;
  82038. private _blurRatio;
  82039. /**
  82040. * Instantiates a Mirror Texture.
  82041. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82042. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82043. * You can then easily use it as a reflectionTexture on a flat surface.
  82044. * In case the surface is not a plane, please consider relying on reflection probes.
  82045. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82046. * @param name
  82047. * @param size
  82048. * @param scene
  82049. * @param generateMipMaps
  82050. * @param type
  82051. * @param samplingMode
  82052. * @param generateDepthBuffer
  82053. */
  82054. constructor(name: string, size: number | {
  82055. width: number;
  82056. height: number;
  82057. } | {
  82058. ratio: number;
  82059. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  82060. private _preparePostProcesses;
  82061. /**
  82062. * Clone the mirror texture.
  82063. * @returns the cloned texture
  82064. */
  82065. clone(): MirrorTexture;
  82066. /**
  82067. * Serialize the texture to a JSON representation you could use in Parse later on
  82068. * @returns the serialized JSON representation
  82069. */
  82070. serialize(): any;
  82071. /**
  82072. * Dispose the texture and release its associated resources.
  82073. */
  82074. dispose(): void;
  82075. }
  82076. }
  82077. declare module BABYLON {
  82078. /**
  82079. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82080. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82081. */
  82082. export class Texture extends BaseTexture {
  82083. /**
  82084. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  82085. */
  82086. static SerializeBuffers: boolean;
  82087. /** @hidden */
  82088. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  82089. /** @hidden */
  82090. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  82091. /** @hidden */
  82092. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  82093. /** nearest is mag = nearest and min = nearest and mip = linear */
  82094. static readonly NEAREST_SAMPLINGMODE: number;
  82095. /** nearest is mag = nearest and min = nearest and mip = linear */
  82096. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  82097. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82098. static readonly BILINEAR_SAMPLINGMODE: number;
  82099. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82100. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  82101. /** Trilinear is mag = linear and min = linear and mip = linear */
  82102. static readonly TRILINEAR_SAMPLINGMODE: number;
  82103. /** Trilinear is mag = linear and min = linear and mip = linear */
  82104. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  82105. /** mag = nearest and min = nearest and mip = nearest */
  82106. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  82107. /** mag = nearest and min = linear and mip = nearest */
  82108. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  82109. /** mag = nearest and min = linear and mip = linear */
  82110. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  82111. /** mag = nearest and min = linear and mip = none */
  82112. static readonly NEAREST_LINEAR: number;
  82113. /** mag = nearest and min = nearest and mip = none */
  82114. static readonly NEAREST_NEAREST: number;
  82115. /** mag = linear and min = nearest and mip = nearest */
  82116. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  82117. /** mag = linear and min = nearest and mip = linear */
  82118. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  82119. /** mag = linear and min = linear and mip = none */
  82120. static readonly LINEAR_LINEAR: number;
  82121. /** mag = linear and min = nearest and mip = none */
  82122. static readonly LINEAR_NEAREST: number;
  82123. /** Explicit coordinates mode */
  82124. static readonly EXPLICIT_MODE: number;
  82125. /** Spherical coordinates mode */
  82126. static readonly SPHERICAL_MODE: number;
  82127. /** Planar coordinates mode */
  82128. static readonly PLANAR_MODE: number;
  82129. /** Cubic coordinates mode */
  82130. static readonly CUBIC_MODE: number;
  82131. /** Projection coordinates mode */
  82132. static readonly PROJECTION_MODE: number;
  82133. /** Inverse Cubic coordinates mode */
  82134. static readonly SKYBOX_MODE: number;
  82135. /** Inverse Cubic coordinates mode */
  82136. static readonly INVCUBIC_MODE: number;
  82137. /** Equirectangular coordinates mode */
  82138. static readonly EQUIRECTANGULAR_MODE: number;
  82139. /** Equirectangular Fixed coordinates mode */
  82140. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  82141. /** Equirectangular Fixed Mirrored coordinates mode */
  82142. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82143. /** Texture is not repeating outside of 0..1 UVs */
  82144. static readonly CLAMP_ADDRESSMODE: number;
  82145. /** Texture is repeating outside of 0..1 UVs */
  82146. static readonly WRAP_ADDRESSMODE: number;
  82147. /** Texture is repeating and mirrored */
  82148. static readonly MIRROR_ADDRESSMODE: number;
  82149. /**
  82150. * 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
  82151. */
  82152. static UseSerializedUrlIfAny: boolean;
  82153. /**
  82154. * Define the url of the texture.
  82155. */
  82156. url: Nullable<string>;
  82157. /**
  82158. * Define an offset on the texture to offset the u coordinates of the UVs
  82159. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82160. */
  82161. uOffset: number;
  82162. /**
  82163. * Define an offset on the texture to offset the v coordinates of the UVs
  82164. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82165. */
  82166. vOffset: number;
  82167. /**
  82168. * Define an offset on the texture to scale the u coordinates of the UVs
  82169. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82170. */
  82171. uScale: number;
  82172. /**
  82173. * Define an offset on the texture to scale the v coordinates of the UVs
  82174. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82175. */
  82176. vScale: number;
  82177. /**
  82178. * Define an offset on the texture to rotate around the u coordinates of the UVs
  82179. * @see http://doc.babylonjs.com/how_to/more_materials
  82180. */
  82181. uAng: number;
  82182. /**
  82183. * Define an offset on the texture to rotate around the v coordinates of the UVs
  82184. * @see http://doc.babylonjs.com/how_to/more_materials
  82185. */
  82186. vAng: number;
  82187. /**
  82188. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  82189. * @see http://doc.babylonjs.com/how_to/more_materials
  82190. */
  82191. wAng: number;
  82192. /**
  82193. * Defines the center of rotation (U)
  82194. */
  82195. uRotationCenter: number;
  82196. /**
  82197. * Defines the center of rotation (V)
  82198. */
  82199. vRotationCenter: number;
  82200. /**
  82201. * Defines the center of rotation (W)
  82202. */
  82203. wRotationCenter: number;
  82204. /**
  82205. * Are mip maps generated for this texture or not.
  82206. */
  82207. readonly noMipmap: boolean;
  82208. /**
  82209. * List of inspectable custom properties (used by the Inspector)
  82210. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82211. */
  82212. inspectableCustomProperties: Nullable<IInspectable[]>;
  82213. private _noMipmap;
  82214. /** @hidden */
  82215. _invertY: boolean;
  82216. private _rowGenerationMatrix;
  82217. private _cachedTextureMatrix;
  82218. private _projectionModeMatrix;
  82219. private _t0;
  82220. private _t1;
  82221. private _t2;
  82222. private _cachedUOffset;
  82223. private _cachedVOffset;
  82224. private _cachedUScale;
  82225. private _cachedVScale;
  82226. private _cachedUAng;
  82227. private _cachedVAng;
  82228. private _cachedWAng;
  82229. private _cachedProjectionMatrixId;
  82230. private _cachedCoordinatesMode;
  82231. /** @hidden */
  82232. protected _initialSamplingMode: number;
  82233. /** @hidden */
  82234. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  82235. private _deleteBuffer;
  82236. protected _format: Nullable<number>;
  82237. private _delayedOnLoad;
  82238. private _delayedOnError;
  82239. /**
  82240. * Observable triggered once the texture has been loaded.
  82241. */
  82242. onLoadObservable: Observable<Texture>;
  82243. protected _isBlocking: boolean;
  82244. /**
  82245. * Is the texture preventing material to render while loading.
  82246. * If false, a default texture will be used instead of the loading one during the preparation step.
  82247. */
  82248. isBlocking: boolean;
  82249. /**
  82250. * Get the current sampling mode associated with the texture.
  82251. */
  82252. readonly samplingMode: number;
  82253. /**
  82254. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  82255. */
  82256. readonly invertY: boolean;
  82257. /**
  82258. * Instantiates a new texture.
  82259. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82260. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82261. * @param url define the url of the picture to load as a texture
  82262. * @param scene define the scene or engine the texture will belong to
  82263. * @param noMipmap define if the texture will require mip maps or not
  82264. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82265. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82266. * @param onLoad define a callback triggered when the texture has been loaded
  82267. * @param onError define a callback triggered when an error occurred during the loading session
  82268. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82269. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82270. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82271. */
  82272. 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);
  82273. /**
  82274. * Update the url (and optional buffer) of this texture if url was null during construction.
  82275. * @param url the url of the texture
  82276. * @param buffer the buffer of the texture (defaults to null)
  82277. * @param onLoad callback called when the texture is loaded (defaults to null)
  82278. */
  82279. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  82280. /**
  82281. * Finish the loading sequence of a texture flagged as delayed load.
  82282. * @hidden
  82283. */
  82284. delayLoad(): void;
  82285. private _prepareRowForTextureGeneration;
  82286. /**
  82287. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  82288. * @returns the transform matrix of the texture.
  82289. */
  82290. getTextureMatrix(): Matrix;
  82291. /**
  82292. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  82293. * @returns The reflection texture transform
  82294. */
  82295. getReflectionTextureMatrix(): Matrix;
  82296. /**
  82297. * Clones the texture.
  82298. * @returns the cloned texture
  82299. */
  82300. clone(): Texture;
  82301. /**
  82302. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  82303. * @returns The JSON representation of the texture
  82304. */
  82305. serialize(): any;
  82306. /**
  82307. * Get the current class name of the texture useful for serialization or dynamic coding.
  82308. * @returns "Texture"
  82309. */
  82310. getClassName(): string;
  82311. /**
  82312. * Dispose the texture and release its associated resources.
  82313. */
  82314. dispose(): void;
  82315. /**
  82316. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  82317. * @param parsedTexture Define the JSON representation of the texture
  82318. * @param scene Define the scene the parsed texture should be instantiated in
  82319. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  82320. * @returns The parsed texture if successful
  82321. */
  82322. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  82323. /**
  82324. * Creates a texture from its base 64 representation.
  82325. * @param data Define the base64 payload without the data: prefix
  82326. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82327. * @param scene Define the scene the texture should belong to
  82328. * @param noMipmap Forces the texture to not create mip map information if true
  82329. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82330. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82331. * @param onLoad define a callback triggered when the texture has been loaded
  82332. * @param onError define a callback triggered when an error occurred during the loading session
  82333. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82334. * @returns the created texture
  82335. */
  82336. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  82337. /**
  82338. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  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 buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82342. * @param scene Define the scene the texture should belong to
  82343. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82344. * @param noMipmap Forces the texture to not create mip map information if true
  82345. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82346. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82347. * @param onLoad define a callback triggered when the texture has been loaded
  82348. * @param onError define a callback triggered when an error occurred during the loading session
  82349. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82350. * @returns the created texture
  82351. */
  82352. 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;
  82353. }
  82354. }
  82355. declare module BABYLON {
  82356. /**
  82357. * PostProcessManager is used to manage one or more post processes or post process pipelines
  82358. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82359. */
  82360. export class PostProcessManager {
  82361. private _scene;
  82362. private _indexBuffer;
  82363. private _vertexBuffers;
  82364. /**
  82365. * Creates a new instance PostProcess
  82366. * @param scene The scene that the post process is associated with.
  82367. */
  82368. constructor(scene: Scene);
  82369. private _prepareBuffers;
  82370. private _buildIndexBuffer;
  82371. /**
  82372. * Rebuilds the vertex buffers of the manager.
  82373. * @hidden
  82374. */
  82375. _rebuild(): void;
  82376. /**
  82377. * Prepares a frame to be run through a post process.
  82378. * @param sourceTexture The input texture to the post procesess. (default: null)
  82379. * @param postProcesses An array of post processes to be run. (default: null)
  82380. * @returns True if the post processes were able to be run.
  82381. * @hidden
  82382. */
  82383. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  82384. /**
  82385. * Manually render a set of post processes to a texture.
  82386. * @param postProcesses An array of post processes to be run.
  82387. * @param targetTexture The target texture to render to.
  82388. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  82389. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  82390. * @param lodLevel defines which lod of the texture to render to
  82391. */
  82392. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  82393. /**
  82394. * Finalize the result of the output of the postprocesses.
  82395. * @param doNotPresent If true the result will not be displayed to the screen.
  82396. * @param targetTexture The target texture to render to.
  82397. * @param faceIndex The index of the face to bind the target texture to.
  82398. * @param postProcesses The array of post processes to render.
  82399. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  82400. * @hidden
  82401. */
  82402. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  82403. /**
  82404. * Disposes of the post process manager.
  82405. */
  82406. dispose(): void;
  82407. }
  82408. }
  82409. declare module BABYLON {
  82410. /** Interface used by value gradients (color, factor, ...) */
  82411. export interface IValueGradient {
  82412. /**
  82413. * Gets or sets the gradient value (between 0 and 1)
  82414. */
  82415. gradient: number;
  82416. }
  82417. /** Class used to store color4 gradient */
  82418. export class ColorGradient implements IValueGradient {
  82419. /**
  82420. * Gets or sets the gradient value (between 0 and 1)
  82421. */
  82422. gradient: number;
  82423. /**
  82424. * Gets or sets first associated color
  82425. */
  82426. color1: Color4;
  82427. /**
  82428. * Gets or sets second associated color
  82429. */
  82430. color2?: Color4;
  82431. /**
  82432. * Will get a color picked randomly between color1 and color2.
  82433. * If color2 is undefined then color1 will be used
  82434. * @param result defines the target Color4 to store the result in
  82435. */
  82436. getColorToRef(result: Color4): void;
  82437. }
  82438. /** Class used to store color 3 gradient */
  82439. export class Color3Gradient implements IValueGradient {
  82440. /**
  82441. * Gets or sets the gradient value (between 0 and 1)
  82442. */
  82443. gradient: number;
  82444. /**
  82445. * Gets or sets the associated color
  82446. */
  82447. color: Color3;
  82448. }
  82449. /** Class used to store factor gradient */
  82450. export class FactorGradient implements IValueGradient {
  82451. /**
  82452. * Gets or sets the gradient value (between 0 and 1)
  82453. */
  82454. gradient: number;
  82455. /**
  82456. * Gets or sets first associated factor
  82457. */
  82458. factor1: number;
  82459. /**
  82460. * Gets or sets second associated factor
  82461. */
  82462. factor2?: number;
  82463. /**
  82464. * Will get a number picked randomly between factor1 and factor2.
  82465. * If factor2 is undefined then factor1 will be used
  82466. * @returns the picked number
  82467. */
  82468. getFactor(): number;
  82469. }
  82470. /**
  82471. * Helper used to simplify some generic gradient tasks
  82472. */
  82473. export class GradientHelper {
  82474. /**
  82475. * Gets the current gradient from an array of IValueGradient
  82476. * @param ratio defines the current ratio to get
  82477. * @param gradients defines the array of IValueGradient
  82478. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  82479. */
  82480. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  82481. }
  82482. }
  82483. declare module BABYLON {
  82484. interface ThinEngine {
  82485. /**
  82486. * Creates a dynamic texture
  82487. * @param width defines the width of the texture
  82488. * @param height defines the height of the texture
  82489. * @param generateMipMaps defines if the engine should generate the mip levels
  82490. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82491. * @returns the dynamic texture inside an InternalTexture
  82492. */
  82493. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  82494. /**
  82495. * Update the content of a dynamic texture
  82496. * @param texture defines the texture to update
  82497. * @param canvas defines the canvas containing the source
  82498. * @param invertY defines if data must be stored with Y axis inverted
  82499. * @param premulAlpha defines if alpha is stored as premultiplied
  82500. * @param format defines the format of the data
  82501. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  82502. */
  82503. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  82504. }
  82505. }
  82506. declare module BABYLON {
  82507. /**
  82508. * A class extending Texture allowing drawing on a texture
  82509. * @see http://doc.babylonjs.com/how_to/dynamictexture
  82510. */
  82511. export class DynamicTexture extends Texture {
  82512. private _generateMipMaps;
  82513. private _canvas;
  82514. private _context;
  82515. private _engine;
  82516. /**
  82517. * Creates a DynamicTexture
  82518. * @param name defines the name of the texture
  82519. * @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
  82520. * @param scene defines the scene where you want the texture
  82521. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  82522. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  82523. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  82524. */
  82525. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  82526. /**
  82527. * Get the current class name of the texture useful for serialization or dynamic coding.
  82528. * @returns "DynamicTexture"
  82529. */
  82530. getClassName(): string;
  82531. /**
  82532. * Gets the current state of canRescale
  82533. */
  82534. readonly canRescale: boolean;
  82535. private _recreate;
  82536. /**
  82537. * Scales the texture
  82538. * @param ratio the scale factor to apply to both width and height
  82539. */
  82540. scale(ratio: number): void;
  82541. /**
  82542. * Resizes the texture
  82543. * @param width the new width
  82544. * @param height the new height
  82545. */
  82546. scaleTo(width: number, height: number): void;
  82547. /**
  82548. * Gets the context of the canvas used by the texture
  82549. * @returns the canvas context of the dynamic texture
  82550. */
  82551. getContext(): CanvasRenderingContext2D;
  82552. /**
  82553. * Clears the texture
  82554. */
  82555. clear(): void;
  82556. /**
  82557. * Updates the texture
  82558. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82559. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  82560. */
  82561. update(invertY?: boolean, premulAlpha?: boolean): void;
  82562. /**
  82563. * Draws text onto the texture
  82564. * @param text defines the text to be drawn
  82565. * @param x defines the placement of the text from the left
  82566. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  82567. * @param font defines the font to be used with font-style, font-size, font-name
  82568. * @param color defines the color used for the text
  82569. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  82570. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82571. * @param update defines whether texture is immediately update (default is true)
  82572. */
  82573. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  82574. /**
  82575. * Clones the texture
  82576. * @returns the clone of the texture.
  82577. */
  82578. clone(): DynamicTexture;
  82579. /**
  82580. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  82581. * @returns a serialized dynamic texture object
  82582. */
  82583. serialize(): any;
  82584. /** @hidden */
  82585. _rebuild(): void;
  82586. }
  82587. }
  82588. declare module BABYLON {
  82589. interface AbstractScene {
  82590. /**
  82591. * The list of procedural textures added to the scene
  82592. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82593. */
  82594. proceduralTextures: Array<ProceduralTexture>;
  82595. }
  82596. /**
  82597. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  82598. * in a given scene.
  82599. */
  82600. export class ProceduralTextureSceneComponent implements ISceneComponent {
  82601. /**
  82602. * The component name helpfull to identify the component in the list of scene components.
  82603. */
  82604. readonly name: string;
  82605. /**
  82606. * The scene the component belongs to.
  82607. */
  82608. scene: Scene;
  82609. /**
  82610. * Creates a new instance of the component for the given scene
  82611. * @param scene Defines the scene to register the component in
  82612. */
  82613. constructor(scene: Scene);
  82614. /**
  82615. * Registers the component in a given scene
  82616. */
  82617. register(): void;
  82618. /**
  82619. * Rebuilds the elements related to this component in case of
  82620. * context lost for instance.
  82621. */
  82622. rebuild(): void;
  82623. /**
  82624. * Disposes the component and the associated ressources.
  82625. */
  82626. dispose(): void;
  82627. private _beforeClear;
  82628. }
  82629. }
  82630. declare module BABYLON {
  82631. interface ThinEngine {
  82632. /**
  82633. * Creates a new render target cube texture
  82634. * @param size defines the size of the texture
  82635. * @param options defines the options used to create the texture
  82636. * @returns a new render target cube texture stored in an InternalTexture
  82637. */
  82638. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  82639. }
  82640. }
  82641. declare module BABYLON {
  82642. /** @hidden */
  82643. export var proceduralVertexShader: {
  82644. name: string;
  82645. shader: string;
  82646. };
  82647. }
  82648. declare module BABYLON {
  82649. /**
  82650. * 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.
  82651. * This is the base class of any Procedural texture and contains most of the shareable code.
  82652. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82653. */
  82654. export class ProceduralTexture extends Texture {
  82655. isCube: boolean;
  82656. /**
  82657. * Define if the texture is enabled or not (disabled texture will not render)
  82658. */
  82659. isEnabled: boolean;
  82660. /**
  82661. * Define if the texture must be cleared before rendering (default is true)
  82662. */
  82663. autoClear: boolean;
  82664. /**
  82665. * Callback called when the texture is generated
  82666. */
  82667. onGenerated: () => void;
  82668. /**
  82669. * Event raised when the texture is generated
  82670. */
  82671. onGeneratedObservable: Observable<ProceduralTexture>;
  82672. /** @hidden */
  82673. _generateMipMaps: boolean;
  82674. /** @hidden **/
  82675. _effect: Effect;
  82676. /** @hidden */
  82677. _textures: {
  82678. [key: string]: Texture;
  82679. };
  82680. private _size;
  82681. private _currentRefreshId;
  82682. private _refreshRate;
  82683. private _vertexBuffers;
  82684. private _indexBuffer;
  82685. private _uniforms;
  82686. private _samplers;
  82687. private _fragment;
  82688. private _floats;
  82689. private _ints;
  82690. private _floatsArrays;
  82691. private _colors3;
  82692. private _colors4;
  82693. private _vectors2;
  82694. private _vectors3;
  82695. private _matrices;
  82696. private _fallbackTexture;
  82697. private _fallbackTextureUsed;
  82698. private _engine;
  82699. private _cachedDefines;
  82700. private _contentUpdateId;
  82701. private _contentData;
  82702. /**
  82703. * Instantiates a new procedural texture.
  82704. * 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.
  82705. * This is the base class of any Procedural texture and contains most of the shareable code.
  82706. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82707. * @param name Define the name of the texture
  82708. * @param size Define the size of the texture to create
  82709. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  82710. * @param scene Define the scene the texture belongs to
  82711. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  82712. * @param generateMipMaps Define if the texture should creates mip maps or not
  82713. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  82714. */
  82715. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  82716. /**
  82717. * The effect that is created when initializing the post process.
  82718. * @returns The created effect corresponding the the postprocess.
  82719. */
  82720. getEffect(): Effect;
  82721. /**
  82722. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  82723. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  82724. */
  82725. getContent(): Nullable<ArrayBufferView>;
  82726. private _createIndexBuffer;
  82727. /** @hidden */
  82728. _rebuild(): void;
  82729. /**
  82730. * Resets the texture in order to recreate its associated resources.
  82731. * This can be called in case of context loss
  82732. */
  82733. reset(): void;
  82734. protected _getDefines(): string;
  82735. /**
  82736. * Is the texture ready to be used ? (rendered at least once)
  82737. * @returns true if ready, otherwise, false.
  82738. */
  82739. isReady(): boolean;
  82740. /**
  82741. * Resets the refresh counter of the texture and start bak from scratch.
  82742. * Could be useful to regenerate the texture if it is setup to render only once.
  82743. */
  82744. resetRefreshCounter(): void;
  82745. /**
  82746. * Set the fragment shader to use in order to render the texture.
  82747. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  82748. */
  82749. setFragment(fragment: any): void;
  82750. /**
  82751. * Define the refresh rate of the texture or the rendering frequency.
  82752. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  82753. */
  82754. refreshRate: number;
  82755. /** @hidden */
  82756. _shouldRender(): boolean;
  82757. /**
  82758. * Get the size the texture is rendering at.
  82759. * @returns the size (texture is always squared)
  82760. */
  82761. getRenderSize(): number;
  82762. /**
  82763. * Resize the texture to new value.
  82764. * @param size Define the new size the texture should have
  82765. * @param generateMipMaps Define whether the new texture should create mip maps
  82766. */
  82767. resize(size: number, generateMipMaps: boolean): void;
  82768. private _checkUniform;
  82769. /**
  82770. * Set a texture in the shader program used to render.
  82771. * @param name Define the name of the uniform samplers as defined in the shader
  82772. * @param texture Define the texture to bind to this sampler
  82773. * @return the texture itself allowing "fluent" like uniform updates
  82774. */
  82775. setTexture(name: string, texture: Texture): ProceduralTexture;
  82776. /**
  82777. * Set a float in the shader.
  82778. * @param name Define the name of the uniform as defined in the shader
  82779. * @param value Define the value to give to the uniform
  82780. * @return the texture itself allowing "fluent" like uniform updates
  82781. */
  82782. setFloat(name: string, value: number): ProceduralTexture;
  82783. /**
  82784. * Set a int in the shader.
  82785. * @param name Define the name of the uniform as defined in the shader
  82786. * @param value Define the value to give to the uniform
  82787. * @return the texture itself allowing "fluent" like uniform updates
  82788. */
  82789. setInt(name: string, value: number): ProceduralTexture;
  82790. /**
  82791. * Set an array of floats 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. setFloats(name: string, value: number[]): ProceduralTexture;
  82797. /**
  82798. * Set a vec3 in the shader from a Color3.
  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. setColor3(name: string, value: Color3): ProceduralTexture;
  82804. /**
  82805. * Set a vec4 in the shader from a Color4.
  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. setColor4(name: string, value: Color4): ProceduralTexture;
  82811. /**
  82812. * Set a vec2 in the shader from a Vector2.
  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. setVector2(name: string, value: Vector2): ProceduralTexture;
  82818. /**
  82819. * Set a vec3 in the shader from a Vector3.
  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. setVector3(name: string, value: Vector3): ProceduralTexture;
  82825. /**
  82826. * Set a mat4 in the shader from a MAtrix.
  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. setMatrix(name: string, value: Matrix): ProceduralTexture;
  82832. /**
  82833. * Render the texture to its associated render target.
  82834. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  82835. */
  82836. render(useCameraPostProcess?: boolean): void;
  82837. /**
  82838. * Clone the texture.
  82839. * @returns the cloned texture
  82840. */
  82841. clone(): ProceduralTexture;
  82842. /**
  82843. * Dispose the texture and release its asoociated resources.
  82844. */
  82845. dispose(): void;
  82846. }
  82847. }
  82848. declare module BABYLON {
  82849. /**
  82850. * This represents the base class for particle system in Babylon.
  82851. * 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.
  82852. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82853. * @example https://doc.babylonjs.com/babylon101/particles
  82854. */
  82855. export class BaseParticleSystem {
  82856. /**
  82857. * Source color is added to the destination color without alpha affecting the result
  82858. */
  82859. static BLENDMODE_ONEONE: number;
  82860. /**
  82861. * Blend current color and particle color using particle’s alpha
  82862. */
  82863. static BLENDMODE_STANDARD: number;
  82864. /**
  82865. * Add current color and particle color multiplied by particle’s alpha
  82866. */
  82867. static BLENDMODE_ADD: number;
  82868. /**
  82869. * Multiply current color with particle color
  82870. */
  82871. static BLENDMODE_MULTIPLY: number;
  82872. /**
  82873. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  82874. */
  82875. static BLENDMODE_MULTIPLYADD: number;
  82876. /**
  82877. * List of animations used by the particle system.
  82878. */
  82879. animations: Animation[];
  82880. /**
  82881. * The id of the Particle system.
  82882. */
  82883. id: string;
  82884. /**
  82885. * The friendly name of the Particle system.
  82886. */
  82887. name: string;
  82888. /**
  82889. * The rendering group used by the Particle system to chose when to render.
  82890. */
  82891. renderingGroupId: number;
  82892. /**
  82893. * The emitter represents the Mesh or position we are attaching the particle system to.
  82894. */
  82895. emitter: Nullable<AbstractMesh | Vector3>;
  82896. /**
  82897. * The maximum number of particles to emit per frame
  82898. */
  82899. emitRate: number;
  82900. /**
  82901. * If you want to launch only a few particles at once, that can be done, as well.
  82902. */
  82903. manualEmitCount: number;
  82904. /**
  82905. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  82906. */
  82907. updateSpeed: number;
  82908. /**
  82909. * The amount of time the particle system is running (depends of the overall update speed).
  82910. */
  82911. targetStopDuration: number;
  82912. /**
  82913. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82914. */
  82915. disposeOnStop: boolean;
  82916. /**
  82917. * Minimum power of emitting particles.
  82918. */
  82919. minEmitPower: number;
  82920. /**
  82921. * Maximum power of emitting particles.
  82922. */
  82923. maxEmitPower: number;
  82924. /**
  82925. * Minimum life time of emitting particles.
  82926. */
  82927. minLifeTime: number;
  82928. /**
  82929. * Maximum life time of emitting particles.
  82930. */
  82931. maxLifeTime: number;
  82932. /**
  82933. * Minimum Size of emitting particles.
  82934. */
  82935. minSize: number;
  82936. /**
  82937. * Maximum Size of emitting particles.
  82938. */
  82939. maxSize: number;
  82940. /**
  82941. * Minimum scale of emitting particles on X axis.
  82942. */
  82943. minScaleX: number;
  82944. /**
  82945. * Maximum scale of emitting particles on X axis.
  82946. */
  82947. maxScaleX: number;
  82948. /**
  82949. * Minimum scale of emitting particles on Y axis.
  82950. */
  82951. minScaleY: number;
  82952. /**
  82953. * Maximum scale of emitting particles on Y axis.
  82954. */
  82955. maxScaleY: number;
  82956. /**
  82957. * Gets or sets the minimal initial rotation in radians.
  82958. */
  82959. minInitialRotation: number;
  82960. /**
  82961. * Gets or sets the maximal initial rotation in radians.
  82962. */
  82963. maxInitialRotation: number;
  82964. /**
  82965. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82966. */
  82967. minAngularSpeed: number;
  82968. /**
  82969. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82970. */
  82971. maxAngularSpeed: number;
  82972. /**
  82973. * The texture used to render each particle. (this can be a spritesheet)
  82974. */
  82975. particleTexture: Nullable<Texture>;
  82976. /**
  82977. * The layer mask we are rendering the particles through.
  82978. */
  82979. layerMask: number;
  82980. /**
  82981. * This can help using your own shader to render the particle system.
  82982. * The according effect will be created
  82983. */
  82984. customShader: any;
  82985. /**
  82986. * By default particle system starts as soon as they are created. This prevents the
  82987. * automatic start to happen and let you decide when to start emitting particles.
  82988. */
  82989. preventAutoStart: boolean;
  82990. private _noiseTexture;
  82991. /**
  82992. * Gets or sets a texture used to add random noise to particle positions
  82993. */
  82994. noiseTexture: Nullable<ProceduralTexture>;
  82995. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82996. noiseStrength: Vector3;
  82997. /**
  82998. * Callback triggered when the particle animation is ending.
  82999. */
  83000. onAnimationEnd: Nullable<() => void>;
  83001. /**
  83002. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  83003. */
  83004. blendMode: number;
  83005. /**
  83006. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  83007. * to override the particles.
  83008. */
  83009. forceDepthWrite: boolean;
  83010. /** 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 */
  83011. preWarmCycles: number;
  83012. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  83013. preWarmStepOffset: number;
  83014. /**
  83015. * 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)
  83016. */
  83017. spriteCellChangeSpeed: number;
  83018. /**
  83019. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83020. */
  83021. startSpriteCellID: number;
  83022. /**
  83023. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83024. */
  83025. endSpriteCellID: number;
  83026. /**
  83027. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83028. */
  83029. spriteCellWidth: number;
  83030. /**
  83031. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83032. */
  83033. spriteCellHeight: number;
  83034. /**
  83035. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83036. */
  83037. spriteRandomStartCell: boolean;
  83038. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83039. translationPivot: Vector2;
  83040. /** @hidden */
  83041. protected _isAnimationSheetEnabled: boolean;
  83042. /**
  83043. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83044. */
  83045. beginAnimationOnStart: boolean;
  83046. /**
  83047. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83048. */
  83049. beginAnimationFrom: number;
  83050. /**
  83051. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83052. */
  83053. beginAnimationTo: number;
  83054. /**
  83055. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83056. */
  83057. beginAnimationLoop: boolean;
  83058. /**
  83059. * Gets or sets a world offset applied to all particles
  83060. */
  83061. worldOffset: Vector3;
  83062. /**
  83063. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  83064. */
  83065. isAnimationSheetEnabled: boolean;
  83066. /**
  83067. * Get hosting scene
  83068. * @returns the scene
  83069. */
  83070. getScene(): Scene;
  83071. /**
  83072. * You can use gravity if you want to give an orientation to your particles.
  83073. */
  83074. gravity: Vector3;
  83075. protected _colorGradients: Nullable<Array<ColorGradient>>;
  83076. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  83077. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  83078. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  83079. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  83080. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  83081. protected _dragGradients: Nullable<Array<FactorGradient>>;
  83082. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  83083. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  83084. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  83085. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  83086. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  83087. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  83088. /**
  83089. * Defines the delay in milliseconds before starting the system (0 by default)
  83090. */
  83091. startDelay: number;
  83092. /**
  83093. * Gets the current list of drag gradients.
  83094. * You must use addDragGradient and removeDragGradient to udpate this list
  83095. * @returns the list of drag gradients
  83096. */
  83097. getDragGradients(): Nullable<Array<FactorGradient>>;
  83098. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83099. limitVelocityDamping: number;
  83100. /**
  83101. * Gets the current list of limit velocity gradients.
  83102. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83103. * @returns the list of limit velocity gradients
  83104. */
  83105. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83106. /**
  83107. * Gets the current list of color gradients.
  83108. * You must use addColorGradient and removeColorGradient to udpate this list
  83109. * @returns the list of color gradients
  83110. */
  83111. getColorGradients(): Nullable<Array<ColorGradient>>;
  83112. /**
  83113. * Gets the current list of size gradients.
  83114. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83115. * @returns the list of size gradients
  83116. */
  83117. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83118. /**
  83119. * Gets the current list of color remap gradients.
  83120. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83121. * @returns the list of color remap gradients
  83122. */
  83123. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83124. /**
  83125. * Gets the current list of alpha remap gradients.
  83126. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83127. * @returns the list of alpha remap gradients
  83128. */
  83129. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83130. /**
  83131. * Gets the current list of life time gradients.
  83132. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83133. * @returns the list of life time gradients
  83134. */
  83135. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83136. /**
  83137. * Gets the current list of angular speed gradients.
  83138. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83139. * @returns the list of angular speed gradients
  83140. */
  83141. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83142. /**
  83143. * Gets the current list of velocity gradients.
  83144. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83145. * @returns the list of velocity gradients
  83146. */
  83147. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83148. /**
  83149. * Gets the current list of start size gradients.
  83150. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83151. * @returns the list of start size gradients
  83152. */
  83153. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83154. /**
  83155. * Gets the current list of emit rate gradients.
  83156. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83157. * @returns the list of emit rate gradients
  83158. */
  83159. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83160. /**
  83161. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83162. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83163. */
  83164. direction1: Vector3;
  83165. /**
  83166. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83167. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83168. */
  83169. direction2: Vector3;
  83170. /**
  83171. * 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.
  83172. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83173. */
  83174. minEmitBox: Vector3;
  83175. /**
  83176. * 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.
  83177. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83178. */
  83179. maxEmitBox: Vector3;
  83180. /**
  83181. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83182. */
  83183. color1: Color4;
  83184. /**
  83185. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83186. */
  83187. color2: Color4;
  83188. /**
  83189. * Color the particle will have at the end of its lifetime
  83190. */
  83191. colorDead: Color4;
  83192. /**
  83193. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  83194. */
  83195. textureMask: Color4;
  83196. /**
  83197. * The particle emitter type defines the emitter used by the particle system.
  83198. * It can be for example box, sphere, or cone...
  83199. */
  83200. particleEmitterType: IParticleEmitterType;
  83201. /** @hidden */
  83202. _isSubEmitter: boolean;
  83203. /**
  83204. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83205. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83206. */
  83207. billboardMode: number;
  83208. protected _isBillboardBased: boolean;
  83209. /**
  83210. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83211. */
  83212. isBillboardBased: boolean;
  83213. /**
  83214. * The scene the particle system belongs to.
  83215. */
  83216. protected _scene: Scene;
  83217. /**
  83218. * Local cache of defines for image processing.
  83219. */
  83220. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  83221. /**
  83222. * Default configuration related to image processing available in the standard Material.
  83223. */
  83224. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  83225. /**
  83226. * Gets the image processing configuration used either in this material.
  83227. */
  83228. /**
  83229. * Sets the Default image processing configuration used either in the this material.
  83230. *
  83231. * If sets to null, the scene one is in use.
  83232. */
  83233. imageProcessingConfiguration: ImageProcessingConfiguration;
  83234. /**
  83235. * Attaches a new image processing configuration to the Standard Material.
  83236. * @param configuration
  83237. */
  83238. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  83239. /** @hidden */
  83240. protected _reset(): void;
  83241. /** @hidden */
  83242. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  83243. /**
  83244. * Instantiates a particle system.
  83245. * 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.
  83246. * @param name The name of the particle system
  83247. */
  83248. constructor(name: string);
  83249. /**
  83250. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83251. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83252. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83253. * @returns the emitter
  83254. */
  83255. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83256. /**
  83257. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83258. * @param radius The radius of the hemisphere to emit from
  83259. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83260. * @returns the emitter
  83261. */
  83262. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  83263. /**
  83264. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83265. * @param radius The radius of the sphere to emit from
  83266. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83267. * @returns the emitter
  83268. */
  83269. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  83270. /**
  83271. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83272. * @param radius The radius of the sphere to emit from
  83273. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83274. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83275. * @returns the emitter
  83276. */
  83277. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  83278. /**
  83279. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83280. * @param radius The radius of the emission cylinder
  83281. * @param height The height of the emission cylinder
  83282. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83283. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83284. * @returns the emitter
  83285. */
  83286. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  83287. /**
  83288. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83289. * @param radius The radius of the cylinder to emit from
  83290. * @param height The height of the emission cylinder
  83291. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83292. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83293. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83294. * @returns the emitter
  83295. */
  83296. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  83297. /**
  83298. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83299. * @param radius The radius of the cone to emit from
  83300. * @param angle The base angle of the cone
  83301. * @returns the emitter
  83302. */
  83303. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  83304. /**
  83305. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83306. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83307. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83308. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83309. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83310. * @returns the emitter
  83311. */
  83312. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83313. }
  83314. }
  83315. declare module BABYLON {
  83316. /**
  83317. * Type of sub emitter
  83318. */
  83319. export enum SubEmitterType {
  83320. /**
  83321. * Attached to the particle over it's lifetime
  83322. */
  83323. ATTACHED = 0,
  83324. /**
  83325. * Created when the particle dies
  83326. */
  83327. END = 1
  83328. }
  83329. /**
  83330. * Sub emitter class used to emit particles from an existing particle
  83331. */
  83332. export class SubEmitter {
  83333. /**
  83334. * the particle system to be used by the sub emitter
  83335. */
  83336. particleSystem: ParticleSystem;
  83337. /**
  83338. * Type of the submitter (Default: END)
  83339. */
  83340. type: SubEmitterType;
  83341. /**
  83342. * 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)
  83343. * Note: This only is supported when using an emitter of type Mesh
  83344. */
  83345. inheritDirection: boolean;
  83346. /**
  83347. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  83348. */
  83349. inheritedVelocityAmount: number;
  83350. /**
  83351. * Creates a sub emitter
  83352. * @param particleSystem the particle system to be used by the sub emitter
  83353. */
  83354. constructor(
  83355. /**
  83356. * the particle system to be used by the sub emitter
  83357. */
  83358. particleSystem: ParticleSystem);
  83359. /**
  83360. * Clones the sub emitter
  83361. * @returns the cloned sub emitter
  83362. */
  83363. clone(): SubEmitter;
  83364. /**
  83365. * Serialize current object to a JSON object
  83366. * @returns the serialized object
  83367. */
  83368. serialize(): any;
  83369. /** @hidden */
  83370. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  83371. /**
  83372. * Creates a new SubEmitter from a serialized JSON version
  83373. * @param serializationObject defines the JSON object to read from
  83374. * @param scene defines the hosting scene
  83375. * @param rootUrl defines the rootUrl for data loading
  83376. * @returns a new SubEmitter
  83377. */
  83378. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  83379. /** Release associated resources */
  83380. dispose(): void;
  83381. }
  83382. }
  83383. declare module BABYLON {
  83384. /** @hidden */
  83385. export var clipPlaneFragmentDeclaration: {
  83386. name: string;
  83387. shader: string;
  83388. };
  83389. }
  83390. declare module BABYLON {
  83391. /** @hidden */
  83392. export var imageProcessingDeclaration: {
  83393. name: string;
  83394. shader: string;
  83395. };
  83396. }
  83397. declare module BABYLON {
  83398. /** @hidden */
  83399. export var imageProcessingFunctions: {
  83400. name: string;
  83401. shader: string;
  83402. };
  83403. }
  83404. declare module BABYLON {
  83405. /** @hidden */
  83406. export var clipPlaneFragment: {
  83407. name: string;
  83408. shader: string;
  83409. };
  83410. }
  83411. declare module BABYLON {
  83412. /** @hidden */
  83413. export var particlesPixelShader: {
  83414. name: string;
  83415. shader: string;
  83416. };
  83417. }
  83418. declare module BABYLON {
  83419. /** @hidden */
  83420. export var clipPlaneVertexDeclaration: {
  83421. name: string;
  83422. shader: string;
  83423. };
  83424. }
  83425. declare module BABYLON {
  83426. /** @hidden */
  83427. export var clipPlaneVertex: {
  83428. name: string;
  83429. shader: string;
  83430. };
  83431. }
  83432. declare module BABYLON {
  83433. /** @hidden */
  83434. export var particlesVertexShader: {
  83435. name: string;
  83436. shader: string;
  83437. };
  83438. }
  83439. declare module BABYLON {
  83440. /**
  83441. * This represents a particle system in Babylon.
  83442. * 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.
  83443. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83444. * @example https://doc.babylonjs.com/babylon101/particles
  83445. */
  83446. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  83447. /**
  83448. * Billboard mode will only apply to Y axis
  83449. */
  83450. static readonly BILLBOARDMODE_Y: number;
  83451. /**
  83452. * Billboard mode will apply to all axes
  83453. */
  83454. static readonly BILLBOARDMODE_ALL: number;
  83455. /**
  83456. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  83457. */
  83458. static readonly BILLBOARDMODE_STRETCHED: number;
  83459. /**
  83460. * This function can be defined to provide custom update for active particles.
  83461. * This function will be called instead of regular update (age, position, color, etc.).
  83462. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  83463. */
  83464. updateFunction: (particles: Particle[]) => void;
  83465. private _emitterWorldMatrix;
  83466. /**
  83467. * This function can be defined to specify initial direction for every new particle.
  83468. * It by default use the emitterType defined function
  83469. */
  83470. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  83471. /**
  83472. * This function can be defined to specify initial position for every new particle.
  83473. * It by default use the emitterType defined function
  83474. */
  83475. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  83476. /**
  83477. * @hidden
  83478. */
  83479. _inheritedVelocityOffset: Vector3;
  83480. /**
  83481. * An event triggered when the system is disposed
  83482. */
  83483. onDisposeObservable: Observable<ParticleSystem>;
  83484. private _onDisposeObserver;
  83485. /**
  83486. * Sets a callback that will be triggered when the system is disposed
  83487. */
  83488. onDispose: () => void;
  83489. private _particles;
  83490. private _epsilon;
  83491. private _capacity;
  83492. private _stockParticles;
  83493. private _newPartsExcess;
  83494. private _vertexData;
  83495. private _vertexBuffer;
  83496. private _vertexBuffers;
  83497. private _spriteBuffer;
  83498. private _indexBuffer;
  83499. private _effect;
  83500. private _customEffect;
  83501. private _cachedDefines;
  83502. private _scaledColorStep;
  83503. private _colorDiff;
  83504. private _scaledDirection;
  83505. private _scaledGravity;
  83506. private _currentRenderId;
  83507. private _alive;
  83508. private _useInstancing;
  83509. private _started;
  83510. private _stopped;
  83511. private _actualFrame;
  83512. private _scaledUpdateSpeed;
  83513. private _vertexBufferSize;
  83514. /** @hidden */
  83515. _currentEmitRateGradient: Nullable<FactorGradient>;
  83516. /** @hidden */
  83517. _currentEmitRate1: number;
  83518. /** @hidden */
  83519. _currentEmitRate2: number;
  83520. /** @hidden */
  83521. _currentStartSizeGradient: Nullable<FactorGradient>;
  83522. /** @hidden */
  83523. _currentStartSize1: number;
  83524. /** @hidden */
  83525. _currentStartSize2: number;
  83526. private readonly _rawTextureWidth;
  83527. private _rampGradientsTexture;
  83528. private _useRampGradients;
  83529. /** Gets or sets a boolean indicating that ramp gradients must be used
  83530. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83531. */
  83532. useRampGradients: boolean;
  83533. /**
  83534. * 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.
  83535. * 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: [])
  83536. */
  83537. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  83538. private _subEmitters;
  83539. /**
  83540. * @hidden
  83541. * If the particle systems emitter should be disposed when the particle system is disposed
  83542. */
  83543. _disposeEmitterOnDispose: boolean;
  83544. /**
  83545. * The current active Sub-systems, this property is used by the root particle system only.
  83546. */
  83547. activeSubSystems: Array<ParticleSystem>;
  83548. private _rootParticleSystem;
  83549. /**
  83550. * Gets the current list of active particles
  83551. */
  83552. readonly particles: Particle[];
  83553. /**
  83554. * Returns the string "ParticleSystem"
  83555. * @returns a string containing the class name
  83556. */
  83557. getClassName(): string;
  83558. /**
  83559. * Instantiates a particle system.
  83560. * 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.
  83561. * @param name The name of the particle system
  83562. * @param capacity The max number of particles alive at the same time
  83563. * @param scene The scene the particle system belongs to
  83564. * @param customEffect a custom effect used to change the way particles are rendered by default
  83565. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  83566. * @param epsilon Offset used to render the particles
  83567. */
  83568. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  83569. private _addFactorGradient;
  83570. private _removeFactorGradient;
  83571. /**
  83572. * Adds a new life time gradient
  83573. * @param gradient defines the gradient to use (between 0 and 1)
  83574. * @param factor defines the life time factor to affect to the specified gradient
  83575. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83576. * @returns the current particle system
  83577. */
  83578. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83579. /**
  83580. * Remove a specific life time gradient
  83581. * @param gradient defines the gradient to remove
  83582. * @returns the current particle system
  83583. */
  83584. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83585. /**
  83586. * Adds a new size gradient
  83587. * @param gradient defines the gradient to use (between 0 and 1)
  83588. * @param factor defines the size 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. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83593. /**
  83594. * Remove a specific size gradient
  83595. * @param gradient defines the gradient to remove
  83596. * @returns the current particle system
  83597. */
  83598. removeSizeGradient(gradient: number): IParticleSystem;
  83599. /**
  83600. * Adds a new color remap gradient
  83601. * @param gradient defines the gradient to use (between 0 and 1)
  83602. * @param min defines the color remap minimal range
  83603. * @param max defines the color remap maximal range
  83604. * @returns the current particle system
  83605. */
  83606. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83607. /**
  83608. * Remove a specific color remap gradient
  83609. * @param gradient defines the gradient to remove
  83610. * @returns the current particle system
  83611. */
  83612. removeColorRemapGradient(gradient: number): IParticleSystem;
  83613. /**
  83614. * Adds a new alpha remap gradient
  83615. * @param gradient defines the gradient to use (between 0 and 1)
  83616. * @param min defines the alpha remap minimal range
  83617. * @param max defines the alpha remap maximal range
  83618. * @returns the current particle system
  83619. */
  83620. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83621. /**
  83622. * Remove a specific alpha remap gradient
  83623. * @param gradient defines the gradient to remove
  83624. * @returns the current particle system
  83625. */
  83626. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  83627. /**
  83628. * Adds a new angular speed gradient
  83629. * @param gradient defines the gradient to use (between 0 and 1)
  83630. * @param factor defines the angular speed to affect to the specified gradient
  83631. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83632. * @returns the current particle system
  83633. */
  83634. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83635. /**
  83636. * Remove a specific angular speed gradient
  83637. * @param gradient defines the gradient to remove
  83638. * @returns the current particle system
  83639. */
  83640. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83641. /**
  83642. * Adds a new velocity gradient
  83643. * @param gradient defines the gradient to use (between 0 and 1)
  83644. * @param factor defines the velocity 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. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83649. /**
  83650. * Remove a specific velocity gradient
  83651. * @param gradient defines the gradient to remove
  83652. * @returns the current particle system
  83653. */
  83654. removeVelocityGradient(gradient: number): IParticleSystem;
  83655. /**
  83656. * Adds a new limit velocity gradient
  83657. * @param gradient defines the gradient to use (between 0 and 1)
  83658. * @param factor defines the limit velocity value 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. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83663. /**
  83664. * Remove a specific limit velocity gradient
  83665. * @param gradient defines the gradient to remove
  83666. * @returns the current particle system
  83667. */
  83668. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83669. /**
  83670. * Adds a new drag gradient
  83671. * @param gradient defines the gradient to use (between 0 and 1)
  83672. * @param factor defines the drag 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. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83677. /**
  83678. * Remove a specific drag gradient
  83679. * @param gradient defines the gradient to remove
  83680. * @returns the current particle system
  83681. */
  83682. removeDragGradient(gradient: number): IParticleSystem;
  83683. /**
  83684. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83685. * @param gradient defines the gradient to use (between 0 and 1)
  83686. * @param factor defines the emit rate 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. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83691. /**
  83692. * Remove a specific emit rate gradient
  83693. * @param gradient defines the gradient to remove
  83694. * @returns the current particle system
  83695. */
  83696. removeEmitRateGradient(gradient: number): IParticleSystem;
  83697. /**
  83698. * Adds a new start size 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 start size 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. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83705. /**
  83706. * Remove a specific start size gradient
  83707. * @param gradient defines the gradient to remove
  83708. * @returns the current particle system
  83709. */
  83710. removeStartSizeGradient(gradient: number): IParticleSystem;
  83711. private _createRampGradientTexture;
  83712. /**
  83713. * Gets the current list of ramp gradients.
  83714. * You must use addRampGradient and removeRampGradient to udpate this list
  83715. * @returns the list of ramp gradients
  83716. */
  83717. getRampGradients(): Nullable<Array<Color3Gradient>>;
  83718. /**
  83719. * Adds a new ramp gradient used to remap particle colors
  83720. * @param gradient defines the gradient to use (between 0 and 1)
  83721. * @param color defines the color to affect to the specified gradient
  83722. * @returns the current particle system
  83723. */
  83724. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  83725. /**
  83726. * Remove a specific ramp gradient
  83727. * @param gradient defines the gradient to remove
  83728. * @returns the current particle system
  83729. */
  83730. removeRampGradient(gradient: number): ParticleSystem;
  83731. /**
  83732. * Adds a new color gradient
  83733. * @param gradient defines the gradient to use (between 0 and 1)
  83734. * @param color1 defines the color to affect to the specified gradient
  83735. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83736. * @returns this particle system
  83737. */
  83738. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83739. /**
  83740. * Remove a specific color gradient
  83741. * @param gradient defines the gradient to remove
  83742. * @returns this particle system
  83743. */
  83744. removeColorGradient(gradient: number): IParticleSystem;
  83745. private _fetchR;
  83746. protected _reset(): void;
  83747. private _resetEffect;
  83748. private _createVertexBuffers;
  83749. private _createIndexBuffer;
  83750. /**
  83751. * Gets the maximum number of particles active at the same time.
  83752. * @returns The max number of active particles.
  83753. */
  83754. getCapacity(): number;
  83755. /**
  83756. * Gets whether there are still active particles in the system.
  83757. * @returns True if it is alive, otherwise false.
  83758. */
  83759. isAlive(): boolean;
  83760. /**
  83761. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83762. * @returns True if it has been started, otherwise false.
  83763. */
  83764. isStarted(): boolean;
  83765. private _prepareSubEmitterInternalArray;
  83766. /**
  83767. * Starts the particle system and begins to emit
  83768. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  83769. */
  83770. start(delay?: number): void;
  83771. /**
  83772. * Stops the particle system.
  83773. * @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.
  83774. */
  83775. stop(stopSubEmitters?: boolean): void;
  83776. /**
  83777. * Remove all active particles
  83778. */
  83779. reset(): void;
  83780. /**
  83781. * @hidden (for internal use only)
  83782. */
  83783. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  83784. /**
  83785. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  83786. * Its lifetime will start back at 0.
  83787. */
  83788. recycleParticle: (particle: Particle) => void;
  83789. private _stopSubEmitters;
  83790. private _createParticle;
  83791. private _removeFromRoot;
  83792. private _emitFromParticle;
  83793. private _update;
  83794. /** @hidden */
  83795. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  83796. /** @hidden */
  83797. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  83798. /** @hidden */
  83799. private _getEffect;
  83800. /**
  83801. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  83802. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  83803. */
  83804. animate(preWarmOnly?: boolean): void;
  83805. private _appendParticleVertices;
  83806. /**
  83807. * Rebuilds the particle system.
  83808. */
  83809. rebuild(): void;
  83810. /**
  83811. * Is this system ready to be used/rendered
  83812. * @return true if the system is ready
  83813. */
  83814. isReady(): boolean;
  83815. private _render;
  83816. /**
  83817. * Renders the particle system in its current state.
  83818. * @returns the current number of particles
  83819. */
  83820. render(): number;
  83821. /**
  83822. * Disposes the particle system and free the associated resources
  83823. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83824. */
  83825. dispose(disposeTexture?: boolean): void;
  83826. /**
  83827. * Clones the particle system.
  83828. * @param name The name of the cloned object
  83829. * @param newEmitter The new emitter to use
  83830. * @returns the cloned particle system
  83831. */
  83832. clone(name: string, newEmitter: any): ParticleSystem;
  83833. /**
  83834. * Serializes the particle system to a JSON object.
  83835. * @returns the JSON object
  83836. */
  83837. serialize(): any;
  83838. /** @hidden */
  83839. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  83840. /** @hidden */
  83841. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  83842. /**
  83843. * Parses a JSON object to create a particle system.
  83844. * @param parsedParticleSystem The JSON object to parse
  83845. * @param scene The scene to create the particle system in
  83846. * @param rootUrl The root url to use to load external dependencies like texture
  83847. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  83848. * @returns the Parsed particle system
  83849. */
  83850. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  83851. }
  83852. }
  83853. declare module BABYLON {
  83854. /**
  83855. * A particle represents one of the element emitted by a particle system.
  83856. * This is mainly define by its coordinates, direction, velocity and age.
  83857. */
  83858. export class Particle {
  83859. /**
  83860. * The particle system the particle belongs to.
  83861. */
  83862. particleSystem: ParticleSystem;
  83863. private static _Count;
  83864. /**
  83865. * Unique ID of the particle
  83866. */
  83867. id: number;
  83868. /**
  83869. * The world position of the particle in the scene.
  83870. */
  83871. position: Vector3;
  83872. /**
  83873. * The world direction of the particle in the scene.
  83874. */
  83875. direction: Vector3;
  83876. /**
  83877. * The color of the particle.
  83878. */
  83879. color: Color4;
  83880. /**
  83881. * The color change of the particle per step.
  83882. */
  83883. colorStep: Color4;
  83884. /**
  83885. * Defines how long will the life of the particle be.
  83886. */
  83887. lifeTime: number;
  83888. /**
  83889. * The current age of the particle.
  83890. */
  83891. age: number;
  83892. /**
  83893. * The current size of the particle.
  83894. */
  83895. size: number;
  83896. /**
  83897. * The current scale of the particle.
  83898. */
  83899. scale: Vector2;
  83900. /**
  83901. * The current angle of the particle.
  83902. */
  83903. angle: number;
  83904. /**
  83905. * Defines how fast is the angle changing.
  83906. */
  83907. angularSpeed: number;
  83908. /**
  83909. * Defines the cell index used by the particle to be rendered from a sprite.
  83910. */
  83911. cellIndex: number;
  83912. /**
  83913. * The information required to support color remapping
  83914. */
  83915. remapData: Vector4;
  83916. /** @hidden */
  83917. _randomCellOffset?: number;
  83918. /** @hidden */
  83919. _initialDirection: Nullable<Vector3>;
  83920. /** @hidden */
  83921. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  83922. /** @hidden */
  83923. _initialStartSpriteCellID: number;
  83924. /** @hidden */
  83925. _initialEndSpriteCellID: number;
  83926. /** @hidden */
  83927. _currentColorGradient: Nullable<ColorGradient>;
  83928. /** @hidden */
  83929. _currentColor1: Color4;
  83930. /** @hidden */
  83931. _currentColor2: Color4;
  83932. /** @hidden */
  83933. _currentSizeGradient: Nullable<FactorGradient>;
  83934. /** @hidden */
  83935. _currentSize1: number;
  83936. /** @hidden */
  83937. _currentSize2: number;
  83938. /** @hidden */
  83939. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  83940. /** @hidden */
  83941. _currentAngularSpeed1: number;
  83942. /** @hidden */
  83943. _currentAngularSpeed2: number;
  83944. /** @hidden */
  83945. _currentVelocityGradient: Nullable<FactorGradient>;
  83946. /** @hidden */
  83947. _currentVelocity1: number;
  83948. /** @hidden */
  83949. _currentVelocity2: number;
  83950. /** @hidden */
  83951. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  83952. /** @hidden */
  83953. _currentLimitVelocity1: number;
  83954. /** @hidden */
  83955. _currentLimitVelocity2: number;
  83956. /** @hidden */
  83957. _currentDragGradient: Nullable<FactorGradient>;
  83958. /** @hidden */
  83959. _currentDrag1: number;
  83960. /** @hidden */
  83961. _currentDrag2: number;
  83962. /** @hidden */
  83963. _randomNoiseCoordinates1: Vector3;
  83964. /** @hidden */
  83965. _randomNoiseCoordinates2: Vector3;
  83966. /**
  83967. * Creates a new instance Particle
  83968. * @param particleSystem the particle system the particle belongs to
  83969. */
  83970. constructor(
  83971. /**
  83972. * The particle system the particle belongs to.
  83973. */
  83974. particleSystem: ParticleSystem);
  83975. private updateCellInfoFromSystem;
  83976. /**
  83977. * Defines how the sprite cell index is updated for the particle
  83978. */
  83979. updateCellIndex(): void;
  83980. /** @hidden */
  83981. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  83982. /** @hidden */
  83983. _inheritParticleInfoToSubEmitters(): void;
  83984. /** @hidden */
  83985. _reset(): void;
  83986. /**
  83987. * Copy the properties of particle to another one.
  83988. * @param other the particle to copy the information to.
  83989. */
  83990. copyTo(other: Particle): void;
  83991. }
  83992. }
  83993. declare module BABYLON {
  83994. /**
  83995. * Particle emitter represents a volume emitting particles.
  83996. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  83997. */
  83998. export interface IParticleEmitterType {
  83999. /**
  84000. * Called by the particle System when the direction is computed for the created particle.
  84001. * @param worldMatrix is the world matrix of the particle system
  84002. * @param directionToUpdate is the direction vector to update with the result
  84003. * @param particle is the particle we are computed the direction for
  84004. */
  84005. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84006. /**
  84007. * Called by the particle System when the position is computed for the created particle.
  84008. * @param worldMatrix is the world matrix of the particle system
  84009. * @param positionToUpdate is the position vector to update with the result
  84010. * @param particle is the particle we are computed the position for
  84011. */
  84012. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84013. /**
  84014. * Clones the current emitter and returns a copy of it
  84015. * @returns the new emitter
  84016. */
  84017. clone(): IParticleEmitterType;
  84018. /**
  84019. * Called by the GPUParticleSystem to setup the update shader
  84020. * @param effect defines the update shader
  84021. */
  84022. applyToShader(effect: Effect): void;
  84023. /**
  84024. * Returns a string to use to update the GPU particles update shader
  84025. * @returns the effect defines string
  84026. */
  84027. getEffectDefines(): string;
  84028. /**
  84029. * Returns a string representing the class name
  84030. * @returns a string containing the class name
  84031. */
  84032. getClassName(): string;
  84033. /**
  84034. * Serializes the particle system to a JSON object.
  84035. * @returns the JSON object
  84036. */
  84037. serialize(): any;
  84038. /**
  84039. * Parse properties from a JSON object
  84040. * @param serializationObject defines the JSON object
  84041. */
  84042. parse(serializationObject: any): void;
  84043. }
  84044. }
  84045. declare module BABYLON {
  84046. /**
  84047. * Particle emitter emitting particles from the inside of a box.
  84048. * It emits the particles randomly between 2 given directions.
  84049. */
  84050. export class BoxParticleEmitter implements IParticleEmitterType {
  84051. /**
  84052. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84053. */
  84054. direction1: Vector3;
  84055. /**
  84056. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84057. */
  84058. direction2: Vector3;
  84059. /**
  84060. * 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.
  84061. */
  84062. minEmitBox: Vector3;
  84063. /**
  84064. * 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.
  84065. */
  84066. maxEmitBox: Vector3;
  84067. /**
  84068. * Creates a new instance BoxParticleEmitter
  84069. */
  84070. constructor();
  84071. /**
  84072. * Called by the particle System when the direction is computed for the created particle.
  84073. * @param worldMatrix is the world matrix of the particle system
  84074. * @param directionToUpdate is the direction vector to update with the result
  84075. * @param particle is the particle we are computed the direction for
  84076. */
  84077. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84078. /**
  84079. * Called by the particle System when the position is computed for the created particle.
  84080. * @param worldMatrix is the world matrix of the particle system
  84081. * @param positionToUpdate is the position vector to update with the result
  84082. * @param particle is the particle we are computed the position for
  84083. */
  84084. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84085. /**
  84086. * Clones the current emitter and returns a copy of it
  84087. * @returns the new emitter
  84088. */
  84089. clone(): BoxParticleEmitter;
  84090. /**
  84091. * Called by the GPUParticleSystem to setup the update shader
  84092. * @param effect defines the update shader
  84093. */
  84094. applyToShader(effect: Effect): void;
  84095. /**
  84096. * Returns a string to use to update the GPU particles update shader
  84097. * @returns a string containng the defines string
  84098. */
  84099. getEffectDefines(): string;
  84100. /**
  84101. * Returns the string "BoxParticleEmitter"
  84102. * @returns a string containing the class name
  84103. */
  84104. getClassName(): string;
  84105. /**
  84106. * Serializes the particle system to a JSON object.
  84107. * @returns the JSON object
  84108. */
  84109. serialize(): any;
  84110. /**
  84111. * Parse properties from a JSON object
  84112. * @param serializationObject defines the JSON object
  84113. */
  84114. parse(serializationObject: any): void;
  84115. }
  84116. }
  84117. declare module BABYLON {
  84118. /**
  84119. * Particle emitter emitting particles from the inside of a cone.
  84120. * It emits the particles alongside the cone volume from the base to the particle.
  84121. * The emission direction might be randomized.
  84122. */
  84123. export class ConeParticleEmitter implements IParticleEmitterType {
  84124. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84125. directionRandomizer: number;
  84126. private _radius;
  84127. private _angle;
  84128. private _height;
  84129. /**
  84130. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  84131. */
  84132. radiusRange: number;
  84133. /**
  84134. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  84135. */
  84136. heightRange: number;
  84137. /**
  84138. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  84139. */
  84140. emitFromSpawnPointOnly: boolean;
  84141. /**
  84142. * Gets or sets the radius of the emission cone
  84143. */
  84144. radius: number;
  84145. /**
  84146. * Gets or sets the angle of the emission cone
  84147. */
  84148. angle: number;
  84149. private _buildHeight;
  84150. /**
  84151. * Creates a new instance ConeParticleEmitter
  84152. * @param radius the radius of the emission cone (1 by default)
  84153. * @param angle the cone base angle (PI by default)
  84154. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  84155. */
  84156. constructor(radius?: number, angle?: number,
  84157. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84158. directionRandomizer?: number);
  84159. /**
  84160. * Called by the particle System when the direction is computed for the created particle.
  84161. * @param worldMatrix is the world matrix of the particle system
  84162. * @param directionToUpdate is the direction vector to update with the result
  84163. * @param particle is the particle we are computed the direction for
  84164. */
  84165. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84166. /**
  84167. * Called by the particle System when the position is computed for the created particle.
  84168. * @param worldMatrix is the world matrix of the particle system
  84169. * @param positionToUpdate is the position vector to update with the result
  84170. * @param particle is the particle we are computed the position for
  84171. */
  84172. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84173. /**
  84174. * Clones the current emitter and returns a copy of it
  84175. * @returns the new emitter
  84176. */
  84177. clone(): ConeParticleEmitter;
  84178. /**
  84179. * Called by the GPUParticleSystem to setup the update shader
  84180. * @param effect defines the update shader
  84181. */
  84182. applyToShader(effect: Effect): void;
  84183. /**
  84184. * Returns a string to use to update the GPU particles update shader
  84185. * @returns a string containng the defines string
  84186. */
  84187. getEffectDefines(): string;
  84188. /**
  84189. * Returns the string "ConeParticleEmitter"
  84190. * @returns a string containing the class name
  84191. */
  84192. getClassName(): string;
  84193. /**
  84194. * Serializes the particle system to a JSON object.
  84195. * @returns the JSON object
  84196. */
  84197. serialize(): any;
  84198. /**
  84199. * Parse properties from a JSON object
  84200. * @param serializationObject defines the JSON object
  84201. */
  84202. parse(serializationObject: any): void;
  84203. }
  84204. }
  84205. declare module BABYLON {
  84206. /**
  84207. * Particle emitter emitting particles from the inside of a cylinder.
  84208. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  84209. */
  84210. export class CylinderParticleEmitter implements IParticleEmitterType {
  84211. /**
  84212. * The radius of the emission cylinder.
  84213. */
  84214. radius: number;
  84215. /**
  84216. * The height of the emission cylinder.
  84217. */
  84218. height: number;
  84219. /**
  84220. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84221. */
  84222. radiusRange: number;
  84223. /**
  84224. * How much to randomize the particle direction [0-1].
  84225. */
  84226. directionRandomizer: number;
  84227. /**
  84228. * Creates a new instance CylinderParticleEmitter
  84229. * @param radius the radius of the emission cylinder (1 by default)
  84230. * @param height the height of the emission cylinder (1 by default)
  84231. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84232. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84233. */
  84234. constructor(
  84235. /**
  84236. * The radius of the emission cylinder.
  84237. */
  84238. radius?: number,
  84239. /**
  84240. * The height of the emission cylinder.
  84241. */
  84242. height?: number,
  84243. /**
  84244. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84245. */
  84246. radiusRange?: number,
  84247. /**
  84248. * How much to randomize the particle direction [0-1].
  84249. */
  84250. directionRandomizer?: number);
  84251. /**
  84252. * Called by the particle System when the direction is computed for the created particle.
  84253. * @param worldMatrix is the world matrix of the particle system
  84254. * @param directionToUpdate is the direction vector to update with the result
  84255. * @param particle is the particle we are computed the direction for
  84256. */
  84257. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84258. /**
  84259. * Called by the particle System when the position is computed for the created particle.
  84260. * @param worldMatrix is the world matrix of the particle system
  84261. * @param positionToUpdate is the position vector to update with the result
  84262. * @param particle is the particle we are computed the position for
  84263. */
  84264. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84265. /**
  84266. * Clones the current emitter and returns a copy of it
  84267. * @returns the new emitter
  84268. */
  84269. clone(): CylinderParticleEmitter;
  84270. /**
  84271. * Called by the GPUParticleSystem to setup the update shader
  84272. * @param effect defines the update shader
  84273. */
  84274. applyToShader(effect: Effect): void;
  84275. /**
  84276. * Returns a string to use to update the GPU particles update shader
  84277. * @returns a string containng the defines string
  84278. */
  84279. getEffectDefines(): string;
  84280. /**
  84281. * Returns the string "CylinderParticleEmitter"
  84282. * @returns a string containing the class name
  84283. */
  84284. getClassName(): string;
  84285. /**
  84286. * Serializes the particle system to a JSON object.
  84287. * @returns the JSON object
  84288. */
  84289. serialize(): any;
  84290. /**
  84291. * Parse properties from a JSON object
  84292. * @param serializationObject defines the JSON object
  84293. */
  84294. parse(serializationObject: any): void;
  84295. }
  84296. /**
  84297. * Particle emitter emitting particles from the inside of a cylinder.
  84298. * It emits the particles randomly between two vectors.
  84299. */
  84300. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  84301. /**
  84302. * The min limit of the emission direction.
  84303. */
  84304. direction1: Vector3;
  84305. /**
  84306. * The max limit of the emission direction.
  84307. */
  84308. direction2: Vector3;
  84309. /**
  84310. * Creates a new instance CylinderDirectedParticleEmitter
  84311. * @param radius the radius of the emission cylinder (1 by default)
  84312. * @param height the height of the emission cylinder (1 by default)
  84313. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84314. * @param direction1 the min limit of the emission direction (up vector by default)
  84315. * @param direction2 the max limit of the emission direction (up vector by default)
  84316. */
  84317. constructor(radius?: number, height?: number, radiusRange?: number,
  84318. /**
  84319. * The min limit of the emission direction.
  84320. */
  84321. direction1?: Vector3,
  84322. /**
  84323. * The max limit of the emission direction.
  84324. */
  84325. direction2?: Vector3);
  84326. /**
  84327. * Called by the particle System when the direction is computed for the created particle.
  84328. * @param worldMatrix is the world matrix of the particle system
  84329. * @param directionToUpdate is the direction vector to update with the result
  84330. * @param particle is the particle we are computed the direction for
  84331. */
  84332. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84333. /**
  84334. * Clones the current emitter and returns a copy of it
  84335. * @returns the new emitter
  84336. */
  84337. clone(): CylinderDirectedParticleEmitter;
  84338. /**
  84339. * Called by the GPUParticleSystem to setup the update shader
  84340. * @param effect defines the update shader
  84341. */
  84342. applyToShader(effect: Effect): void;
  84343. /**
  84344. * Returns a string to use to update the GPU particles update shader
  84345. * @returns a string containng the defines string
  84346. */
  84347. getEffectDefines(): string;
  84348. /**
  84349. * Returns the string "CylinderDirectedParticleEmitter"
  84350. * @returns a string containing the class name
  84351. */
  84352. getClassName(): string;
  84353. /**
  84354. * Serializes the particle system to a JSON object.
  84355. * @returns the JSON object
  84356. */
  84357. serialize(): any;
  84358. /**
  84359. * Parse properties from a JSON object
  84360. * @param serializationObject defines the JSON object
  84361. */
  84362. parse(serializationObject: any): void;
  84363. }
  84364. }
  84365. declare module BABYLON {
  84366. /**
  84367. * Particle emitter emitting particles from the inside of a hemisphere.
  84368. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  84369. */
  84370. export class HemisphericParticleEmitter implements IParticleEmitterType {
  84371. /**
  84372. * The radius of the emission hemisphere.
  84373. */
  84374. radius: number;
  84375. /**
  84376. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84377. */
  84378. radiusRange: number;
  84379. /**
  84380. * How much to randomize the particle direction [0-1].
  84381. */
  84382. directionRandomizer: number;
  84383. /**
  84384. * Creates a new instance HemisphericParticleEmitter
  84385. * @param radius the radius of the emission hemisphere (1 by default)
  84386. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84387. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84388. */
  84389. constructor(
  84390. /**
  84391. * The radius of the emission hemisphere.
  84392. */
  84393. radius?: number,
  84394. /**
  84395. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84396. */
  84397. radiusRange?: number,
  84398. /**
  84399. * How much to randomize the particle direction [0-1].
  84400. */
  84401. directionRandomizer?: number);
  84402. /**
  84403. * Called by the particle System when the direction is computed for the created particle.
  84404. * @param worldMatrix is the world matrix of the particle system
  84405. * @param directionToUpdate is the direction vector to update with the result
  84406. * @param particle is the particle we are computed the direction for
  84407. */
  84408. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84409. /**
  84410. * Called by the particle System when the position is computed for the created particle.
  84411. * @param worldMatrix is the world matrix of the particle system
  84412. * @param positionToUpdate is the position vector to update with the result
  84413. * @param particle is the particle we are computed the position for
  84414. */
  84415. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84416. /**
  84417. * Clones the current emitter and returns a copy of it
  84418. * @returns the new emitter
  84419. */
  84420. clone(): HemisphericParticleEmitter;
  84421. /**
  84422. * Called by the GPUParticleSystem to setup the update shader
  84423. * @param effect defines the update shader
  84424. */
  84425. applyToShader(effect: Effect): void;
  84426. /**
  84427. * Returns a string to use to update the GPU particles update shader
  84428. * @returns a string containng the defines string
  84429. */
  84430. getEffectDefines(): string;
  84431. /**
  84432. * Returns the string "HemisphericParticleEmitter"
  84433. * @returns a string containing the class name
  84434. */
  84435. getClassName(): string;
  84436. /**
  84437. * Serializes the particle system to a JSON object.
  84438. * @returns the JSON object
  84439. */
  84440. serialize(): any;
  84441. /**
  84442. * Parse properties from a JSON object
  84443. * @param serializationObject defines the JSON object
  84444. */
  84445. parse(serializationObject: any): void;
  84446. }
  84447. }
  84448. declare module BABYLON {
  84449. /**
  84450. * Particle emitter emitting particles from a point.
  84451. * It emits the particles randomly between 2 given directions.
  84452. */
  84453. export class PointParticleEmitter implements IParticleEmitterType {
  84454. /**
  84455. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84456. */
  84457. direction1: Vector3;
  84458. /**
  84459. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84460. */
  84461. direction2: Vector3;
  84462. /**
  84463. * Creates a new instance PointParticleEmitter
  84464. */
  84465. constructor();
  84466. /**
  84467. * Called by the particle System when the direction is computed for the created particle.
  84468. * @param worldMatrix is the world matrix of the particle system
  84469. * @param directionToUpdate is the direction vector to update with the result
  84470. * @param particle is the particle we are computed the direction for
  84471. */
  84472. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84473. /**
  84474. * Called by the particle System when the position is computed for the created particle.
  84475. * @param worldMatrix is the world matrix of the particle system
  84476. * @param positionToUpdate is the position vector to update with the result
  84477. * @param particle is the particle we are computed the position for
  84478. */
  84479. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84480. /**
  84481. * Clones the current emitter and returns a copy of it
  84482. * @returns the new emitter
  84483. */
  84484. clone(): PointParticleEmitter;
  84485. /**
  84486. * Called by the GPUParticleSystem to setup the update shader
  84487. * @param effect defines the update shader
  84488. */
  84489. applyToShader(effect: Effect): void;
  84490. /**
  84491. * Returns a string to use to update the GPU particles update shader
  84492. * @returns a string containng the defines string
  84493. */
  84494. getEffectDefines(): string;
  84495. /**
  84496. * Returns the string "PointParticleEmitter"
  84497. * @returns a string containing the class name
  84498. */
  84499. getClassName(): string;
  84500. /**
  84501. * Serializes the particle system to a JSON object.
  84502. * @returns the JSON object
  84503. */
  84504. serialize(): any;
  84505. /**
  84506. * Parse properties from a JSON object
  84507. * @param serializationObject defines the JSON object
  84508. */
  84509. parse(serializationObject: any): void;
  84510. }
  84511. }
  84512. declare module BABYLON {
  84513. /**
  84514. * Particle emitter emitting particles from the inside of a sphere.
  84515. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  84516. */
  84517. export class SphereParticleEmitter implements IParticleEmitterType {
  84518. /**
  84519. * The radius of the emission sphere.
  84520. */
  84521. radius: number;
  84522. /**
  84523. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84524. */
  84525. radiusRange: number;
  84526. /**
  84527. * How much to randomize the particle direction [0-1].
  84528. */
  84529. directionRandomizer: number;
  84530. /**
  84531. * Creates a new instance SphereParticleEmitter
  84532. * @param radius the radius of the emission sphere (1 by default)
  84533. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84534. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84535. */
  84536. constructor(
  84537. /**
  84538. * The radius of the emission sphere.
  84539. */
  84540. radius?: number,
  84541. /**
  84542. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84543. */
  84544. radiusRange?: number,
  84545. /**
  84546. * How much to randomize the particle direction [0-1].
  84547. */
  84548. directionRandomizer?: number);
  84549. /**
  84550. * Called by the particle System when the direction is computed for the created particle.
  84551. * @param worldMatrix is the world matrix of the particle system
  84552. * @param directionToUpdate is the direction vector to update with the result
  84553. * @param particle is the particle we are computed the direction for
  84554. */
  84555. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84556. /**
  84557. * Called by the particle System when the position is computed for the created particle.
  84558. * @param worldMatrix is the world matrix of the particle system
  84559. * @param positionToUpdate is the position vector to update with the result
  84560. * @param particle is the particle we are computed the position for
  84561. */
  84562. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84563. /**
  84564. * Clones the current emitter and returns a copy of it
  84565. * @returns the new emitter
  84566. */
  84567. clone(): SphereParticleEmitter;
  84568. /**
  84569. * Called by the GPUParticleSystem to setup the update shader
  84570. * @param effect defines the update shader
  84571. */
  84572. applyToShader(effect: Effect): void;
  84573. /**
  84574. * Returns a string to use to update the GPU particles update shader
  84575. * @returns a string containng the defines string
  84576. */
  84577. getEffectDefines(): string;
  84578. /**
  84579. * Returns the string "SphereParticleEmitter"
  84580. * @returns a string containing the class name
  84581. */
  84582. getClassName(): string;
  84583. /**
  84584. * Serializes the particle system to a JSON object.
  84585. * @returns the JSON object
  84586. */
  84587. serialize(): any;
  84588. /**
  84589. * Parse properties from a JSON object
  84590. * @param serializationObject defines the JSON object
  84591. */
  84592. parse(serializationObject: any): void;
  84593. }
  84594. /**
  84595. * Particle emitter emitting particles from the inside of a sphere.
  84596. * It emits the particles randomly between two vectors.
  84597. */
  84598. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  84599. /**
  84600. * The min limit of the emission direction.
  84601. */
  84602. direction1: Vector3;
  84603. /**
  84604. * The max limit of the emission direction.
  84605. */
  84606. direction2: Vector3;
  84607. /**
  84608. * Creates a new instance SphereDirectedParticleEmitter
  84609. * @param radius the radius of the emission sphere (1 by default)
  84610. * @param direction1 the min limit of the emission direction (up vector by default)
  84611. * @param direction2 the max limit of the emission direction (up vector by default)
  84612. */
  84613. constructor(radius?: number,
  84614. /**
  84615. * The min limit of the emission direction.
  84616. */
  84617. direction1?: Vector3,
  84618. /**
  84619. * The max limit of the emission direction.
  84620. */
  84621. direction2?: Vector3);
  84622. /**
  84623. * Called by the particle System when the direction is computed for the created particle.
  84624. * @param worldMatrix is the world matrix of the particle system
  84625. * @param directionToUpdate is the direction vector to update with the result
  84626. * @param particle is the particle we are computed the direction for
  84627. */
  84628. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84629. /**
  84630. * Clones the current emitter and returns a copy of it
  84631. * @returns the new emitter
  84632. */
  84633. clone(): SphereDirectedParticleEmitter;
  84634. /**
  84635. * Called by the GPUParticleSystem to setup the update shader
  84636. * @param effect defines the update shader
  84637. */
  84638. applyToShader(effect: Effect): void;
  84639. /**
  84640. * Returns a string to use to update the GPU particles update shader
  84641. * @returns a string containng the defines string
  84642. */
  84643. getEffectDefines(): string;
  84644. /**
  84645. * Returns the string "SphereDirectedParticleEmitter"
  84646. * @returns a string containing the class name
  84647. */
  84648. getClassName(): string;
  84649. /**
  84650. * Serializes the particle system to a JSON object.
  84651. * @returns the JSON object
  84652. */
  84653. serialize(): any;
  84654. /**
  84655. * Parse properties from a JSON object
  84656. * @param serializationObject defines the JSON object
  84657. */
  84658. parse(serializationObject: any): void;
  84659. }
  84660. }
  84661. declare module BABYLON {
  84662. /**
  84663. * Interface representing a particle system in Babylon.js.
  84664. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  84665. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  84666. */
  84667. export interface IParticleSystem {
  84668. /**
  84669. * List of animations used by the particle system.
  84670. */
  84671. animations: Animation[];
  84672. /**
  84673. * The id of the Particle system.
  84674. */
  84675. id: string;
  84676. /**
  84677. * The name of the Particle system.
  84678. */
  84679. name: string;
  84680. /**
  84681. * The emitter represents the Mesh or position we are attaching the particle system to.
  84682. */
  84683. emitter: Nullable<AbstractMesh | Vector3>;
  84684. /**
  84685. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84686. */
  84687. isBillboardBased: boolean;
  84688. /**
  84689. * The rendering group used by the Particle system to chose when to render.
  84690. */
  84691. renderingGroupId: number;
  84692. /**
  84693. * The layer mask we are rendering the particles through.
  84694. */
  84695. layerMask: number;
  84696. /**
  84697. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84698. */
  84699. updateSpeed: number;
  84700. /**
  84701. * The amount of time the particle system is running (depends of the overall update speed).
  84702. */
  84703. targetStopDuration: number;
  84704. /**
  84705. * The texture used to render each particle. (this can be a spritesheet)
  84706. */
  84707. particleTexture: Nullable<Texture>;
  84708. /**
  84709. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  84710. */
  84711. blendMode: number;
  84712. /**
  84713. * Minimum life time of emitting particles.
  84714. */
  84715. minLifeTime: number;
  84716. /**
  84717. * Maximum life time of emitting particles.
  84718. */
  84719. maxLifeTime: number;
  84720. /**
  84721. * Minimum Size of emitting particles.
  84722. */
  84723. minSize: number;
  84724. /**
  84725. * Maximum Size of emitting particles.
  84726. */
  84727. maxSize: number;
  84728. /**
  84729. * Minimum scale of emitting particles on X axis.
  84730. */
  84731. minScaleX: number;
  84732. /**
  84733. * Maximum scale of emitting particles on X axis.
  84734. */
  84735. maxScaleX: number;
  84736. /**
  84737. * Minimum scale of emitting particles on Y axis.
  84738. */
  84739. minScaleY: number;
  84740. /**
  84741. * Maximum scale of emitting particles on Y axis.
  84742. */
  84743. maxScaleY: number;
  84744. /**
  84745. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  84746. */
  84747. color1: Color4;
  84748. /**
  84749. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  84750. */
  84751. color2: Color4;
  84752. /**
  84753. * Color the particle will have at the end of its lifetime.
  84754. */
  84755. colorDead: Color4;
  84756. /**
  84757. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  84758. */
  84759. emitRate: number;
  84760. /**
  84761. * You can use gravity if you want to give an orientation to your particles.
  84762. */
  84763. gravity: Vector3;
  84764. /**
  84765. * Minimum power of emitting particles.
  84766. */
  84767. minEmitPower: number;
  84768. /**
  84769. * Maximum power of emitting particles.
  84770. */
  84771. maxEmitPower: number;
  84772. /**
  84773. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84774. */
  84775. minAngularSpeed: number;
  84776. /**
  84777. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84778. */
  84779. maxAngularSpeed: number;
  84780. /**
  84781. * Gets or sets the minimal initial rotation in radians.
  84782. */
  84783. minInitialRotation: number;
  84784. /**
  84785. * Gets or sets the maximal initial rotation in radians.
  84786. */
  84787. maxInitialRotation: number;
  84788. /**
  84789. * The particle emitter type defines the emitter used by the particle system.
  84790. * It can be for example box, sphere, or cone...
  84791. */
  84792. particleEmitterType: Nullable<IParticleEmitterType>;
  84793. /**
  84794. * Defines the delay in milliseconds before starting the system (0 by default)
  84795. */
  84796. startDelay: number;
  84797. /**
  84798. * 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
  84799. */
  84800. preWarmCycles: number;
  84801. /**
  84802. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  84803. */
  84804. preWarmStepOffset: number;
  84805. /**
  84806. * 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)
  84807. */
  84808. spriteCellChangeSpeed: number;
  84809. /**
  84810. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84811. */
  84812. startSpriteCellID: number;
  84813. /**
  84814. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84815. */
  84816. endSpriteCellID: number;
  84817. /**
  84818. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84819. */
  84820. spriteCellWidth: number;
  84821. /**
  84822. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84823. */
  84824. spriteCellHeight: number;
  84825. /**
  84826. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84827. */
  84828. spriteRandomStartCell: boolean;
  84829. /**
  84830. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  84831. */
  84832. isAnimationSheetEnabled: boolean;
  84833. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84834. translationPivot: Vector2;
  84835. /**
  84836. * Gets or sets a texture used to add random noise to particle positions
  84837. */
  84838. noiseTexture: Nullable<BaseTexture>;
  84839. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84840. noiseStrength: Vector3;
  84841. /**
  84842. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84843. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84844. */
  84845. billboardMode: number;
  84846. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84847. limitVelocityDamping: number;
  84848. /**
  84849. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84850. */
  84851. beginAnimationOnStart: boolean;
  84852. /**
  84853. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84854. */
  84855. beginAnimationFrom: number;
  84856. /**
  84857. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84858. */
  84859. beginAnimationTo: number;
  84860. /**
  84861. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84862. */
  84863. beginAnimationLoop: boolean;
  84864. /**
  84865. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84866. */
  84867. disposeOnStop: boolean;
  84868. /**
  84869. * Gets the maximum number of particles active at the same time.
  84870. * @returns The max number of active particles.
  84871. */
  84872. getCapacity(): number;
  84873. /**
  84874. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84875. * @returns True if it has been started, otherwise false.
  84876. */
  84877. isStarted(): boolean;
  84878. /**
  84879. * Animates the particle system for this frame.
  84880. */
  84881. animate(): void;
  84882. /**
  84883. * Renders the particle system in its current state.
  84884. * @returns the current number of particles
  84885. */
  84886. render(): number;
  84887. /**
  84888. * Dispose the particle system and frees its associated resources.
  84889. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84890. */
  84891. dispose(disposeTexture?: boolean): void;
  84892. /**
  84893. * Clones the particle system.
  84894. * @param name The name of the cloned object
  84895. * @param newEmitter The new emitter to use
  84896. * @returns the cloned particle system
  84897. */
  84898. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  84899. /**
  84900. * Serializes the particle system to a JSON object.
  84901. * @returns the JSON object
  84902. */
  84903. serialize(): any;
  84904. /**
  84905. * Rebuild the particle system
  84906. */
  84907. rebuild(): void;
  84908. /**
  84909. * Starts the particle system and begins to emit
  84910. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  84911. */
  84912. start(delay?: number): void;
  84913. /**
  84914. * Stops the particle system.
  84915. */
  84916. stop(): void;
  84917. /**
  84918. * Remove all active particles
  84919. */
  84920. reset(): void;
  84921. /**
  84922. * Is this system ready to be used/rendered
  84923. * @return true if the system is ready
  84924. */
  84925. isReady(): boolean;
  84926. /**
  84927. * Adds a new color gradient
  84928. * @param gradient defines the gradient to use (between 0 and 1)
  84929. * @param color1 defines the color to affect to the specified gradient
  84930. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84931. * @returns the current particle system
  84932. */
  84933. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84934. /**
  84935. * Remove a specific color gradient
  84936. * @param gradient defines the gradient to remove
  84937. * @returns the current particle system
  84938. */
  84939. removeColorGradient(gradient: number): IParticleSystem;
  84940. /**
  84941. * Adds a new size gradient
  84942. * @param gradient defines the gradient to use (between 0 and 1)
  84943. * @param factor defines the size factor to affect to the specified gradient
  84944. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84945. * @returns the current particle system
  84946. */
  84947. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84948. /**
  84949. * Remove a specific size gradient
  84950. * @param gradient defines the gradient to remove
  84951. * @returns the current particle system
  84952. */
  84953. removeSizeGradient(gradient: number): IParticleSystem;
  84954. /**
  84955. * Gets the current list of color gradients.
  84956. * You must use addColorGradient and removeColorGradient to udpate this list
  84957. * @returns the list of color gradients
  84958. */
  84959. getColorGradients(): Nullable<Array<ColorGradient>>;
  84960. /**
  84961. * Gets the current list of size gradients.
  84962. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84963. * @returns the list of size gradients
  84964. */
  84965. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84966. /**
  84967. * Gets the current list of angular speed gradients.
  84968. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84969. * @returns the list of angular speed gradients
  84970. */
  84971. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84972. /**
  84973. * Adds a new angular speed gradient
  84974. * @param gradient defines the gradient to use (between 0 and 1)
  84975. * @param factor defines the angular speed to affect to the specified gradient
  84976. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84977. * @returns the current particle system
  84978. */
  84979. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84980. /**
  84981. * Remove a specific angular speed gradient
  84982. * @param gradient defines the gradient to remove
  84983. * @returns the current particle system
  84984. */
  84985. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84986. /**
  84987. * Gets the current list of velocity gradients.
  84988. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84989. * @returns the list of velocity gradients
  84990. */
  84991. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84992. /**
  84993. * Adds a new velocity gradient
  84994. * @param gradient defines the gradient to use (between 0 and 1)
  84995. * @param factor defines the velocity to affect to the specified gradient
  84996. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84997. * @returns the current particle system
  84998. */
  84999. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85000. /**
  85001. * Remove a specific velocity gradient
  85002. * @param gradient defines the gradient to remove
  85003. * @returns the current particle system
  85004. */
  85005. removeVelocityGradient(gradient: number): IParticleSystem;
  85006. /**
  85007. * Gets the current list of limit velocity gradients.
  85008. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85009. * @returns the list of limit velocity gradients
  85010. */
  85011. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85012. /**
  85013. * Adds a new limit velocity gradient
  85014. * @param gradient defines the gradient to use (between 0 and 1)
  85015. * @param factor defines the limit velocity to affect to the specified gradient
  85016. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85017. * @returns the current particle system
  85018. */
  85019. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85020. /**
  85021. * Remove a specific limit velocity gradient
  85022. * @param gradient defines the gradient to remove
  85023. * @returns the current particle system
  85024. */
  85025. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85026. /**
  85027. * Adds a new drag gradient
  85028. * @param gradient defines the gradient to use (between 0 and 1)
  85029. * @param factor defines the drag 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. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85034. /**
  85035. * Remove a specific drag gradient
  85036. * @param gradient defines the gradient to remove
  85037. * @returns the current particle system
  85038. */
  85039. removeDragGradient(gradient: number): IParticleSystem;
  85040. /**
  85041. * Gets the current list of drag gradients.
  85042. * You must use addDragGradient and removeDragGradient to udpate this list
  85043. * @returns the list of drag gradients
  85044. */
  85045. getDragGradients(): Nullable<Array<FactorGradient>>;
  85046. /**
  85047. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85048. * @param gradient defines the gradient to use (between 0 and 1)
  85049. * @param factor defines the emit rate to affect to the specified gradient
  85050. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85051. * @returns the current particle system
  85052. */
  85053. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85054. /**
  85055. * Remove a specific emit rate gradient
  85056. * @param gradient defines the gradient to remove
  85057. * @returns the current particle system
  85058. */
  85059. removeEmitRateGradient(gradient: number): IParticleSystem;
  85060. /**
  85061. * Gets the current list of emit rate gradients.
  85062. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85063. * @returns the list of emit rate gradients
  85064. */
  85065. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85066. /**
  85067. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85068. * @param gradient defines the gradient to use (between 0 and 1)
  85069. * @param factor defines the start size to affect to the specified gradient
  85070. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85071. * @returns the current particle system
  85072. */
  85073. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85074. /**
  85075. * Remove a specific start size gradient
  85076. * @param gradient defines the gradient to remove
  85077. * @returns the current particle system
  85078. */
  85079. removeStartSizeGradient(gradient: number): IParticleSystem;
  85080. /**
  85081. * Gets the current list of start size gradients.
  85082. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85083. * @returns the list of start size gradients
  85084. */
  85085. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85086. /**
  85087. * Adds a new life time gradient
  85088. * @param gradient defines the gradient to use (between 0 and 1)
  85089. * @param factor defines the life time factor to affect to the specified gradient
  85090. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85091. * @returns the current particle system
  85092. */
  85093. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85094. /**
  85095. * Remove a specific life time gradient
  85096. * @param gradient defines the gradient to remove
  85097. * @returns the current particle system
  85098. */
  85099. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85100. /**
  85101. * Gets the current list of life time gradients.
  85102. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85103. * @returns the list of life time gradients
  85104. */
  85105. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85106. /**
  85107. * Gets the current list of color gradients.
  85108. * You must use addColorGradient and removeColorGradient to udpate this list
  85109. * @returns the list of color gradients
  85110. */
  85111. getColorGradients(): Nullable<Array<ColorGradient>>;
  85112. /**
  85113. * Adds a new ramp gradient used to remap particle colors
  85114. * @param gradient defines the gradient to use (between 0 and 1)
  85115. * @param color defines the color to affect to the specified gradient
  85116. * @returns the current particle system
  85117. */
  85118. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  85119. /**
  85120. * Gets the current list of ramp gradients.
  85121. * You must use addRampGradient and removeRampGradient to udpate this list
  85122. * @returns the list of ramp gradients
  85123. */
  85124. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85125. /** Gets or sets a boolean indicating that ramp gradients must be used
  85126. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85127. */
  85128. useRampGradients: boolean;
  85129. /**
  85130. * Adds a new color remap gradient
  85131. * @param gradient defines the gradient to use (between 0 and 1)
  85132. * @param min defines the color remap minimal range
  85133. * @param max defines the color remap maximal range
  85134. * @returns the current particle system
  85135. */
  85136. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85137. /**
  85138. * Gets the current list of color remap gradients.
  85139. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85140. * @returns the list of color remap gradients
  85141. */
  85142. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85143. /**
  85144. * Adds a new alpha remap gradient
  85145. * @param gradient defines the gradient to use (between 0 and 1)
  85146. * @param min defines the alpha remap minimal range
  85147. * @param max defines the alpha remap maximal range
  85148. * @returns the current particle system
  85149. */
  85150. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85151. /**
  85152. * Gets the current list of alpha remap gradients.
  85153. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85154. * @returns the list of alpha remap gradients
  85155. */
  85156. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85157. /**
  85158. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85159. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85160. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85161. * @returns the emitter
  85162. */
  85163. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85164. /**
  85165. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85166. * @param radius The radius of the hemisphere to emit from
  85167. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85168. * @returns the emitter
  85169. */
  85170. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  85171. /**
  85172. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85173. * @param radius The radius of the sphere to emit from
  85174. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85175. * @returns the emitter
  85176. */
  85177. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  85178. /**
  85179. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85180. * @param radius The radius of the sphere to emit from
  85181. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85182. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85183. * @returns the emitter
  85184. */
  85185. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85186. /**
  85187. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85188. * @param radius The radius of the emission cylinder
  85189. * @param height The height of the emission cylinder
  85190. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85191. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85192. * @returns the emitter
  85193. */
  85194. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  85195. /**
  85196. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85197. * @param radius The radius of the cylinder to emit from
  85198. * @param height The height of the emission cylinder
  85199. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85200. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85201. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85202. * @returns the emitter
  85203. */
  85204. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85205. /**
  85206. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85207. * @param radius The radius of the cone to emit from
  85208. * @param angle The base angle of the cone
  85209. * @returns the emitter
  85210. */
  85211. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  85212. /**
  85213. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85214. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85215. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85216. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85217. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85218. * @returns the emitter
  85219. */
  85220. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85221. /**
  85222. * Get hosting scene
  85223. * @returns the scene
  85224. */
  85225. getScene(): Scene;
  85226. }
  85227. }
  85228. declare module BABYLON {
  85229. /**
  85230. * Creates an instance based on a source mesh.
  85231. */
  85232. export class InstancedMesh extends AbstractMesh {
  85233. private _sourceMesh;
  85234. private _currentLOD;
  85235. /** @hidden */
  85236. _indexInSourceMeshInstanceArray: number;
  85237. constructor(name: string, source: Mesh);
  85238. /**
  85239. * Returns the string "InstancedMesh".
  85240. */
  85241. getClassName(): string;
  85242. /** Gets the list of lights affecting that mesh */
  85243. readonly lightSources: Light[];
  85244. _resyncLightSources(): void;
  85245. _resyncLighSource(light: Light): void;
  85246. _removeLightSource(light: Light, dispose: boolean): void;
  85247. /**
  85248. * If the source mesh receives shadows
  85249. */
  85250. readonly receiveShadows: boolean;
  85251. /**
  85252. * The material of the source mesh
  85253. */
  85254. readonly material: Nullable<Material>;
  85255. /**
  85256. * Visibility of the source mesh
  85257. */
  85258. readonly visibility: number;
  85259. /**
  85260. * Skeleton of the source mesh
  85261. */
  85262. readonly skeleton: Nullable<Skeleton>;
  85263. /**
  85264. * Rendering ground id of the source mesh
  85265. */
  85266. renderingGroupId: number;
  85267. /**
  85268. * Returns the total number of vertices (integer).
  85269. */
  85270. getTotalVertices(): number;
  85271. /**
  85272. * Returns a positive integer : the total number of indices in this mesh geometry.
  85273. * @returns the numner of indices or zero if the mesh has no geometry.
  85274. */
  85275. getTotalIndices(): number;
  85276. /**
  85277. * The source mesh of the instance
  85278. */
  85279. readonly sourceMesh: Mesh;
  85280. /**
  85281. * Is this node ready to be used/rendered
  85282. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85283. * @return {boolean} is it ready
  85284. */
  85285. isReady(completeCheck?: boolean): boolean;
  85286. /**
  85287. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85288. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  85289. * @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.
  85290. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  85291. */
  85292. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  85293. /**
  85294. * Sets the vertex data of the mesh geometry for the requested `kind`.
  85295. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  85296. * The `data` are either a numeric array either a Float32Array.
  85297. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  85298. * 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).
  85299. * Note that a new underlying VertexBuffer object is created each call.
  85300. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  85301. *
  85302. * Possible `kind` values :
  85303. * - VertexBuffer.PositionKind
  85304. * - VertexBuffer.UVKind
  85305. * - VertexBuffer.UV2Kind
  85306. * - VertexBuffer.UV3Kind
  85307. * - VertexBuffer.UV4Kind
  85308. * - VertexBuffer.UV5Kind
  85309. * - VertexBuffer.UV6Kind
  85310. * - VertexBuffer.ColorKind
  85311. * - VertexBuffer.MatricesIndicesKind
  85312. * - VertexBuffer.MatricesIndicesExtraKind
  85313. * - VertexBuffer.MatricesWeightsKind
  85314. * - VertexBuffer.MatricesWeightsExtraKind
  85315. *
  85316. * Returns the Mesh.
  85317. */
  85318. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  85319. /**
  85320. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  85321. * If the mesh has no geometry, it is simply returned as it is.
  85322. * The `data` are either a numeric array either a Float32Array.
  85323. * No new underlying VertexBuffer object is created.
  85324. * 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.
  85325. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  85326. *
  85327. * Possible `kind` values :
  85328. * - VertexBuffer.PositionKind
  85329. * - VertexBuffer.UVKind
  85330. * - VertexBuffer.UV2Kind
  85331. * - VertexBuffer.UV3Kind
  85332. * - VertexBuffer.UV4Kind
  85333. * - VertexBuffer.UV5Kind
  85334. * - VertexBuffer.UV6Kind
  85335. * - VertexBuffer.ColorKind
  85336. * - VertexBuffer.MatricesIndicesKind
  85337. * - VertexBuffer.MatricesIndicesExtraKind
  85338. * - VertexBuffer.MatricesWeightsKind
  85339. * - VertexBuffer.MatricesWeightsExtraKind
  85340. *
  85341. * Returns the Mesh.
  85342. */
  85343. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  85344. /**
  85345. * Sets the mesh indices.
  85346. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  85347. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  85348. * This method creates a new index buffer each call.
  85349. * Returns the Mesh.
  85350. */
  85351. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  85352. /**
  85353. * Boolean : True if the mesh owns the requested kind of data.
  85354. */
  85355. isVerticesDataPresent(kind: string): boolean;
  85356. /**
  85357. * Returns an array of indices (IndicesArray).
  85358. */
  85359. getIndices(): Nullable<IndicesArray>;
  85360. readonly _positions: Nullable<Vector3[]>;
  85361. /**
  85362. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  85363. * This means the mesh underlying bounding box and sphere are recomputed.
  85364. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  85365. * @returns the current mesh
  85366. */
  85367. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  85368. /** @hidden */
  85369. _preActivate(): InstancedMesh;
  85370. /** @hidden */
  85371. _activate(renderId: number, intermediateRendering: boolean): boolean;
  85372. /** @hidden */
  85373. _postActivate(): void;
  85374. getWorldMatrix(): Matrix;
  85375. readonly isAnInstance: boolean;
  85376. /**
  85377. * Returns the current associated LOD AbstractMesh.
  85378. */
  85379. getLOD(camera: Camera): AbstractMesh;
  85380. /** @hidden */
  85381. _syncSubMeshes(): InstancedMesh;
  85382. /** @hidden */
  85383. _generatePointsArray(): boolean;
  85384. /**
  85385. * Creates a new InstancedMesh from the current mesh.
  85386. * - name (string) : the cloned mesh name
  85387. * - newParent (optional Node) : the optional Node to parent the clone to.
  85388. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  85389. *
  85390. * Returns the clone.
  85391. */
  85392. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85393. /**
  85394. * Disposes the InstancedMesh.
  85395. * Returns nothing.
  85396. */
  85397. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85398. }
  85399. }
  85400. declare module BABYLON {
  85401. /**
  85402. * Defines the options associated with the creation of a shader material.
  85403. */
  85404. export interface IShaderMaterialOptions {
  85405. /**
  85406. * Does the material work in alpha blend mode
  85407. */
  85408. needAlphaBlending: boolean;
  85409. /**
  85410. * Does the material work in alpha test mode
  85411. */
  85412. needAlphaTesting: boolean;
  85413. /**
  85414. * The list of attribute names used in the shader
  85415. */
  85416. attributes: string[];
  85417. /**
  85418. * The list of unifrom names used in the shader
  85419. */
  85420. uniforms: string[];
  85421. /**
  85422. * The list of UBO names used in the shader
  85423. */
  85424. uniformBuffers: string[];
  85425. /**
  85426. * The list of sampler names used in the shader
  85427. */
  85428. samplers: string[];
  85429. /**
  85430. * The list of defines used in the shader
  85431. */
  85432. defines: string[];
  85433. }
  85434. /**
  85435. * 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.
  85436. *
  85437. * This returned material effects how the mesh will look based on the code in the shaders.
  85438. *
  85439. * @see http://doc.babylonjs.com/how_to/shader_material
  85440. */
  85441. export class ShaderMaterial extends Material {
  85442. private _shaderPath;
  85443. private _options;
  85444. private _textures;
  85445. private _textureArrays;
  85446. private _floats;
  85447. private _ints;
  85448. private _floatsArrays;
  85449. private _colors3;
  85450. private _colors3Arrays;
  85451. private _colors4;
  85452. private _colors4Arrays;
  85453. private _vectors2;
  85454. private _vectors3;
  85455. private _vectors4;
  85456. private _matrices;
  85457. private _matrices3x3;
  85458. private _matrices2x2;
  85459. private _vectors2Arrays;
  85460. private _vectors3Arrays;
  85461. private _vectors4Arrays;
  85462. private _cachedWorldViewMatrix;
  85463. private _cachedWorldViewProjectionMatrix;
  85464. private _renderId;
  85465. /**
  85466. * Instantiate a new shader material.
  85467. * 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.
  85468. * This returned material effects how the mesh will look based on the code in the shaders.
  85469. * @see http://doc.babylonjs.com/how_to/shader_material
  85470. * @param name Define the name of the material in the scene
  85471. * @param scene Define the scene the material belongs to
  85472. * @param shaderPath Defines the route to the shader code in one of three ways:
  85473. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  85474. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  85475. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  85476. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  85477. * @param options Define the options used to create the shader
  85478. */
  85479. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  85480. /**
  85481. * Gets the options used to compile the shader.
  85482. * They can be modified to trigger a new compilation
  85483. */
  85484. readonly options: IShaderMaterialOptions;
  85485. /**
  85486. * Gets the current class name of the material e.g. "ShaderMaterial"
  85487. * Mainly use in serialization.
  85488. * @returns the class name
  85489. */
  85490. getClassName(): string;
  85491. /**
  85492. * Specifies if the material will require alpha blending
  85493. * @returns a boolean specifying if alpha blending is needed
  85494. */
  85495. needAlphaBlending(): boolean;
  85496. /**
  85497. * Specifies if this material should be rendered in alpha test mode
  85498. * @returns a boolean specifying if an alpha test is needed.
  85499. */
  85500. needAlphaTesting(): boolean;
  85501. private _checkUniform;
  85502. /**
  85503. * Set a texture in the shader.
  85504. * @param name Define the name of the uniform samplers as defined in the shader
  85505. * @param texture Define the texture to bind to this sampler
  85506. * @return the material itself allowing "fluent" like uniform updates
  85507. */
  85508. setTexture(name: string, texture: Texture): ShaderMaterial;
  85509. /**
  85510. * Set a texture array in the shader.
  85511. * @param name Define the name of the uniform sampler array as defined in the shader
  85512. * @param textures Define the list of textures to bind to this sampler
  85513. * @return the material itself allowing "fluent" like uniform updates
  85514. */
  85515. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  85516. /**
  85517. * Set a float in the shader.
  85518. * @param name Define the name of the uniform as defined in the shader
  85519. * @param value Define the value to give to the uniform
  85520. * @return the material itself allowing "fluent" like uniform updates
  85521. */
  85522. setFloat(name: string, value: number): ShaderMaterial;
  85523. /**
  85524. * Set a int in the shader.
  85525. * @param name Define the name of the uniform as defined in the shader
  85526. * @param value Define the value to give to the uniform
  85527. * @return the material itself allowing "fluent" like uniform updates
  85528. */
  85529. setInt(name: string, value: number): ShaderMaterial;
  85530. /**
  85531. * Set an array of floats 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. setFloats(name: string, value: number[]): ShaderMaterial;
  85537. /**
  85538. * Set a vec3 in the shader from a Color3.
  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. setColor3(name: string, value: Color3): ShaderMaterial;
  85544. /**
  85545. * Set a vec3 array in the shader from a Color3 array.
  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. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  85551. /**
  85552. * Set a vec4 in the shader from a Color4.
  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. setColor4(name: string, value: Color4): ShaderMaterial;
  85558. /**
  85559. * Set a vec4 array in the shader from a Color4 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. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  85565. /**
  85566. * Set a vec2 in the shader from a Vector2.
  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. setVector2(name: string, value: Vector2): ShaderMaterial;
  85572. /**
  85573. * Set a vec3 in the shader from a Vector3.
  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. setVector3(name: string, value: Vector3): ShaderMaterial;
  85579. /**
  85580. * Set a vec4 in the shader from a Vector4.
  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. setVector4(name: string, value: Vector4): ShaderMaterial;
  85586. /**
  85587. * Set a mat4 in the shader from a Matrix.
  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. setMatrix(name: string, value: Matrix): ShaderMaterial;
  85593. /**
  85594. * Set a mat3 in the shader from a Float32Array.
  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. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  85600. /**
  85601. * Set a mat2 in the shader from a Float32Array.
  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. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  85607. /**
  85608. * Set a vec2 array in the shader from a number array.
  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. setArray2(name: string, value: number[]): ShaderMaterial;
  85614. /**
  85615. * Set a vec3 array in the shader from a number array.
  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. setArray3(name: string, value: number[]): ShaderMaterial;
  85621. /**
  85622. * Set a vec4 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. setArray4(name: string, value: number[]): ShaderMaterial;
  85628. private _checkCache;
  85629. /**
  85630. * Specifies that the submesh is ready to be used
  85631. * @param mesh defines the mesh to check
  85632. * @param subMesh defines which submesh to check
  85633. * @param useInstances specifies that instances should be used
  85634. * @returns a boolean indicating that the submesh is ready or not
  85635. */
  85636. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85637. /**
  85638. * Checks if the material is ready to render the requested mesh
  85639. * @param mesh Define the mesh to render
  85640. * @param useInstances Define whether or not the material is used with instances
  85641. * @returns true if ready, otherwise false
  85642. */
  85643. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85644. /**
  85645. * Binds the world matrix to the material
  85646. * @param world defines the world transformation matrix
  85647. */
  85648. bindOnlyWorldMatrix(world: Matrix): void;
  85649. /**
  85650. * Binds the material to the mesh
  85651. * @param world defines the world transformation matrix
  85652. * @param mesh defines the mesh to bind the material to
  85653. */
  85654. bind(world: Matrix, mesh?: Mesh): void;
  85655. /**
  85656. * Gets the active textures from the material
  85657. * @returns an array of textures
  85658. */
  85659. getActiveTextures(): BaseTexture[];
  85660. /**
  85661. * Specifies if the material uses a texture
  85662. * @param texture defines the texture to check against the material
  85663. * @returns a boolean specifying if the material uses the texture
  85664. */
  85665. hasTexture(texture: BaseTexture): boolean;
  85666. /**
  85667. * Makes a duplicate of the material, and gives it a new name
  85668. * @param name defines the new name for the duplicated material
  85669. * @returns the cloned material
  85670. */
  85671. clone(name: string): ShaderMaterial;
  85672. /**
  85673. * Disposes the material
  85674. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85675. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85676. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85677. */
  85678. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85679. /**
  85680. * Serializes this material in a JSON representation
  85681. * @returns the serialized material object
  85682. */
  85683. serialize(): any;
  85684. /**
  85685. * Creates a shader material from parsed shader material data
  85686. * @param source defines the JSON represnetation of the material
  85687. * @param scene defines the hosting scene
  85688. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  85689. * @returns a new material
  85690. */
  85691. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  85692. }
  85693. }
  85694. declare module BABYLON {
  85695. /** @hidden */
  85696. export var colorPixelShader: {
  85697. name: string;
  85698. shader: string;
  85699. };
  85700. }
  85701. declare module BABYLON {
  85702. /** @hidden */
  85703. export var colorVertexShader: {
  85704. name: string;
  85705. shader: string;
  85706. };
  85707. }
  85708. declare module BABYLON {
  85709. /**
  85710. * Line mesh
  85711. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  85712. */
  85713. export class LinesMesh extends Mesh {
  85714. /**
  85715. * If vertex color should be applied to the mesh
  85716. */
  85717. readonly useVertexColor?: boolean | undefined;
  85718. /**
  85719. * If vertex alpha should be applied to the mesh
  85720. */
  85721. readonly useVertexAlpha?: boolean | undefined;
  85722. /**
  85723. * Color of the line (Default: White)
  85724. */
  85725. color: Color3;
  85726. /**
  85727. * Alpha of the line (Default: 1)
  85728. */
  85729. alpha: number;
  85730. /**
  85731. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  85732. * This margin is expressed in world space coordinates, so its value may vary.
  85733. * Default value is 0.1
  85734. */
  85735. intersectionThreshold: number;
  85736. private _colorShader;
  85737. private color4;
  85738. /**
  85739. * Creates a new LinesMesh
  85740. * @param name defines the name
  85741. * @param scene defines the hosting scene
  85742. * @param parent defines the parent mesh if any
  85743. * @param source defines the optional source LinesMesh used to clone data from
  85744. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  85745. * When false, achieved by calling a clone(), also passing False.
  85746. * This will make creation of children, recursive.
  85747. * @param useVertexColor defines if this LinesMesh supports vertex color
  85748. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  85749. */
  85750. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  85751. /**
  85752. * If vertex color should be applied to the mesh
  85753. */
  85754. useVertexColor?: boolean | undefined,
  85755. /**
  85756. * If vertex alpha should be applied to the mesh
  85757. */
  85758. useVertexAlpha?: boolean | undefined);
  85759. private _addClipPlaneDefine;
  85760. private _removeClipPlaneDefine;
  85761. isReady(): boolean;
  85762. /**
  85763. * Returns the string "LineMesh"
  85764. */
  85765. getClassName(): string;
  85766. /**
  85767. * @hidden
  85768. */
  85769. /**
  85770. * @hidden
  85771. */
  85772. material: Material;
  85773. /**
  85774. * @hidden
  85775. */
  85776. readonly checkCollisions: boolean;
  85777. /** @hidden */
  85778. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  85779. /** @hidden */
  85780. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  85781. /**
  85782. * Disposes of the line mesh
  85783. * @param doNotRecurse If children should be disposed
  85784. */
  85785. dispose(doNotRecurse?: boolean): void;
  85786. /**
  85787. * Returns a new LineMesh object cloned from the current one.
  85788. */
  85789. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85790. /**
  85791. * Creates a new InstancedLinesMesh object from the mesh model.
  85792. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  85793. * @param name defines the name of the new instance
  85794. * @returns a new InstancedLinesMesh
  85795. */
  85796. createInstance(name: string): InstancedLinesMesh;
  85797. }
  85798. /**
  85799. * Creates an instance based on a source LinesMesh
  85800. */
  85801. export class InstancedLinesMesh extends InstancedMesh {
  85802. /**
  85803. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  85804. * This margin is expressed in world space coordinates, so its value may vary.
  85805. * Initilized with the intersectionThreshold value of the source LinesMesh
  85806. */
  85807. intersectionThreshold: number;
  85808. constructor(name: string, source: LinesMesh);
  85809. /**
  85810. * Returns the string "InstancedLinesMesh".
  85811. */
  85812. getClassName(): string;
  85813. }
  85814. }
  85815. declare module BABYLON {
  85816. /** @hidden */
  85817. export var linePixelShader: {
  85818. name: string;
  85819. shader: string;
  85820. };
  85821. }
  85822. declare module BABYLON {
  85823. /** @hidden */
  85824. export var lineVertexShader: {
  85825. name: string;
  85826. shader: string;
  85827. };
  85828. }
  85829. declare module BABYLON {
  85830. interface AbstractMesh {
  85831. /**
  85832. * Gets the edgesRenderer associated with the mesh
  85833. */
  85834. edgesRenderer: Nullable<EdgesRenderer>;
  85835. }
  85836. interface LinesMesh {
  85837. /**
  85838. * Enables the edge rendering mode on the mesh.
  85839. * This mode makes the mesh edges visible
  85840. * @param epsilon defines the maximal distance between two angles to detect a face
  85841. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85842. * @returns the currentAbstractMesh
  85843. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85844. */
  85845. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  85846. }
  85847. interface InstancedLinesMesh {
  85848. /**
  85849. * Enables the edge rendering mode on the mesh.
  85850. * This mode makes the mesh edges visible
  85851. * @param epsilon defines the maximal distance between two angles to detect a face
  85852. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85853. * @returns the current InstancedLinesMesh
  85854. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85855. */
  85856. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  85857. }
  85858. /**
  85859. * Defines the minimum contract an Edges renderer should follow.
  85860. */
  85861. export interface IEdgesRenderer extends IDisposable {
  85862. /**
  85863. * Gets or sets a boolean indicating if the edgesRenderer is active
  85864. */
  85865. isEnabled: boolean;
  85866. /**
  85867. * Renders the edges of the attached mesh,
  85868. */
  85869. render(): void;
  85870. /**
  85871. * Checks wether or not the edges renderer is ready to render.
  85872. * @return true if ready, otherwise false.
  85873. */
  85874. isReady(): boolean;
  85875. }
  85876. /**
  85877. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  85878. */
  85879. export class EdgesRenderer implements IEdgesRenderer {
  85880. /**
  85881. * Define the size of the edges with an orthographic camera
  85882. */
  85883. edgesWidthScalerForOrthographic: number;
  85884. /**
  85885. * Define the size of the edges with a perspective camera
  85886. */
  85887. edgesWidthScalerForPerspective: number;
  85888. protected _source: AbstractMesh;
  85889. protected _linesPositions: number[];
  85890. protected _linesNormals: number[];
  85891. protected _linesIndices: number[];
  85892. protected _epsilon: number;
  85893. protected _indicesCount: number;
  85894. protected _lineShader: ShaderMaterial;
  85895. protected _ib: DataBuffer;
  85896. protected _buffers: {
  85897. [key: string]: Nullable<VertexBuffer>;
  85898. };
  85899. protected _checkVerticesInsteadOfIndices: boolean;
  85900. private _meshRebuildObserver;
  85901. private _meshDisposeObserver;
  85902. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  85903. isEnabled: boolean;
  85904. /**
  85905. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  85906. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  85907. * @param source Mesh used to create edges
  85908. * @param epsilon sum of angles in adjacency to check for edge
  85909. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  85910. * @param generateEdgesLines - should generate Lines or only prepare resources.
  85911. */
  85912. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  85913. protected _prepareRessources(): void;
  85914. /** @hidden */
  85915. _rebuild(): void;
  85916. /**
  85917. * Releases the required resources for the edges renderer
  85918. */
  85919. dispose(): void;
  85920. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  85921. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  85922. /**
  85923. * Checks if the pair of p0 and p1 is en edge
  85924. * @param faceIndex
  85925. * @param edge
  85926. * @param faceNormals
  85927. * @param p0
  85928. * @param p1
  85929. * @private
  85930. */
  85931. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  85932. /**
  85933. * push line into the position, normal and index buffer
  85934. * @protected
  85935. */
  85936. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  85937. /**
  85938. * Generates lines edges from adjacencjes
  85939. * @private
  85940. */
  85941. _generateEdgesLines(): void;
  85942. /**
  85943. * Checks wether or not the edges renderer is ready to render.
  85944. * @return true if ready, otherwise false.
  85945. */
  85946. isReady(): boolean;
  85947. /**
  85948. * Renders the edges of the attached mesh,
  85949. */
  85950. render(): void;
  85951. }
  85952. /**
  85953. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  85954. */
  85955. export class LineEdgesRenderer extends EdgesRenderer {
  85956. /**
  85957. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  85958. * @param source LineMesh used to generate edges
  85959. * @param epsilon not important (specified angle for edge detection)
  85960. * @param checkVerticesInsteadOfIndices not important for LineMesh
  85961. */
  85962. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  85963. /**
  85964. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  85965. */
  85966. _generateEdgesLines(): void;
  85967. }
  85968. }
  85969. declare module BABYLON {
  85970. /**
  85971. * This represents the object necessary to create a rendering group.
  85972. * This is exclusively used and created by the rendering manager.
  85973. * To modify the behavior, you use the available helpers in your scene or meshes.
  85974. * @hidden
  85975. */
  85976. export class RenderingGroup {
  85977. index: number;
  85978. private static _zeroVector;
  85979. private _scene;
  85980. private _opaqueSubMeshes;
  85981. private _transparentSubMeshes;
  85982. private _alphaTestSubMeshes;
  85983. private _depthOnlySubMeshes;
  85984. private _particleSystems;
  85985. private _spriteManagers;
  85986. private _opaqueSortCompareFn;
  85987. private _alphaTestSortCompareFn;
  85988. private _transparentSortCompareFn;
  85989. private _renderOpaque;
  85990. private _renderAlphaTest;
  85991. private _renderTransparent;
  85992. /** @hidden */
  85993. _edgesRenderers: SmartArray<IEdgesRenderer>;
  85994. onBeforeTransparentRendering: () => void;
  85995. /**
  85996. * Set the opaque sort comparison function.
  85997. * If null the sub meshes will be render in the order they were created
  85998. */
  85999. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86000. /**
  86001. * Set the alpha test sort comparison function.
  86002. * If null the sub meshes will be render in the order they were created
  86003. */
  86004. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86005. /**
  86006. * Set the transparent sort comparison function.
  86007. * If null the sub meshes will be render in the order they were created
  86008. */
  86009. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86010. /**
  86011. * Creates a new rendering group.
  86012. * @param index The rendering group index
  86013. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  86014. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  86015. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  86016. */
  86017. 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>);
  86018. /**
  86019. * Render all the sub meshes contained in the group.
  86020. * @param customRenderFunction Used to override the default render behaviour of the group.
  86021. * @returns true if rendered some submeshes.
  86022. */
  86023. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  86024. /**
  86025. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  86026. * @param subMeshes The submeshes to render
  86027. */
  86028. private renderOpaqueSorted;
  86029. /**
  86030. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  86031. * @param subMeshes The submeshes to render
  86032. */
  86033. private renderAlphaTestSorted;
  86034. /**
  86035. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  86036. * @param subMeshes The submeshes to render
  86037. */
  86038. private renderTransparentSorted;
  86039. /**
  86040. * Renders the submeshes in a specified order.
  86041. * @param subMeshes The submeshes to sort before render
  86042. * @param sortCompareFn The comparison function use to sort
  86043. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  86044. * @param transparent Specifies to activate blending if true
  86045. */
  86046. private static renderSorted;
  86047. /**
  86048. * Renders the submeshes in the order they were dispatched (no sort applied).
  86049. * @param subMeshes The submeshes to render
  86050. */
  86051. private static renderUnsorted;
  86052. /**
  86053. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86054. * are rendered back to front if in the same alpha index.
  86055. *
  86056. * @param a The first submesh
  86057. * @param b The second submesh
  86058. * @returns The result of the comparison
  86059. */
  86060. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  86061. /**
  86062. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86063. * are rendered back to front.
  86064. *
  86065. * @param a The first submesh
  86066. * @param b The second submesh
  86067. * @returns The result of the comparison
  86068. */
  86069. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  86070. /**
  86071. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86072. * are rendered front to back (prevent overdraw).
  86073. *
  86074. * @param a The first submesh
  86075. * @param b The second submesh
  86076. * @returns The result of the comparison
  86077. */
  86078. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  86079. /**
  86080. * Resets the different lists of submeshes to prepare a new frame.
  86081. */
  86082. prepare(): void;
  86083. dispose(): void;
  86084. /**
  86085. * Inserts the submesh in its correct queue depending on its material.
  86086. * @param subMesh The submesh to dispatch
  86087. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86088. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86089. */
  86090. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86091. dispatchSprites(spriteManager: ISpriteManager): void;
  86092. dispatchParticles(particleSystem: IParticleSystem): void;
  86093. private _renderParticles;
  86094. private _renderSprites;
  86095. }
  86096. }
  86097. declare module BABYLON {
  86098. /**
  86099. * Interface describing the different options available in the rendering manager
  86100. * regarding Auto Clear between groups.
  86101. */
  86102. export interface IRenderingManagerAutoClearSetup {
  86103. /**
  86104. * Defines whether or not autoclear is enable.
  86105. */
  86106. autoClear: boolean;
  86107. /**
  86108. * Defines whether or not to autoclear the depth buffer.
  86109. */
  86110. depth: boolean;
  86111. /**
  86112. * Defines whether or not to autoclear the stencil buffer.
  86113. */
  86114. stencil: boolean;
  86115. }
  86116. /**
  86117. * This class is used by the onRenderingGroupObservable
  86118. */
  86119. export class RenderingGroupInfo {
  86120. /**
  86121. * The Scene that being rendered
  86122. */
  86123. scene: Scene;
  86124. /**
  86125. * The camera currently used for the rendering pass
  86126. */
  86127. camera: Nullable<Camera>;
  86128. /**
  86129. * The ID of the renderingGroup being processed
  86130. */
  86131. renderingGroupId: number;
  86132. }
  86133. /**
  86134. * This is the manager responsible of all the rendering for meshes sprites and particles.
  86135. * It is enable to manage the different groups as well as the different necessary sort functions.
  86136. * This should not be used directly aside of the few static configurations
  86137. */
  86138. export class RenderingManager {
  86139. /**
  86140. * The max id used for rendering groups (not included)
  86141. */
  86142. static MAX_RENDERINGGROUPS: number;
  86143. /**
  86144. * The min id used for rendering groups (included)
  86145. */
  86146. static MIN_RENDERINGGROUPS: number;
  86147. /**
  86148. * Used to globally prevent autoclearing scenes.
  86149. */
  86150. static AUTOCLEAR: boolean;
  86151. /**
  86152. * @hidden
  86153. */
  86154. _useSceneAutoClearSetup: boolean;
  86155. private _scene;
  86156. private _renderingGroups;
  86157. private _depthStencilBufferAlreadyCleaned;
  86158. private _autoClearDepthStencil;
  86159. private _customOpaqueSortCompareFn;
  86160. private _customAlphaTestSortCompareFn;
  86161. private _customTransparentSortCompareFn;
  86162. private _renderingGroupInfo;
  86163. /**
  86164. * Instantiates a new rendering group for a particular scene
  86165. * @param scene Defines the scene the groups belongs to
  86166. */
  86167. constructor(scene: Scene);
  86168. private _clearDepthStencilBuffer;
  86169. /**
  86170. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  86171. * @hidden
  86172. */
  86173. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  86174. /**
  86175. * Resets the different information of the group to prepare a new frame
  86176. * @hidden
  86177. */
  86178. reset(): void;
  86179. /**
  86180. * Dispose and release the group and its associated resources.
  86181. * @hidden
  86182. */
  86183. dispose(): void;
  86184. /**
  86185. * Clear the info related to rendering groups preventing retention points during dispose.
  86186. */
  86187. freeRenderingGroups(): void;
  86188. private _prepareRenderingGroup;
  86189. /**
  86190. * Add a sprite manager to the rendering manager in order to render it this frame.
  86191. * @param spriteManager Define the sprite manager to render
  86192. */
  86193. dispatchSprites(spriteManager: ISpriteManager): void;
  86194. /**
  86195. * Add a particle system to the rendering manager in order to render it this frame.
  86196. * @param particleSystem Define the particle system to render
  86197. */
  86198. dispatchParticles(particleSystem: IParticleSystem): void;
  86199. /**
  86200. * Add a submesh to the manager in order to render it this frame
  86201. * @param subMesh The submesh to dispatch
  86202. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86203. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86204. */
  86205. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86206. /**
  86207. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86208. * This allowed control for front to back rendering or reversly depending of the special needs.
  86209. *
  86210. * @param renderingGroupId The rendering group id corresponding to its index
  86211. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86212. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86213. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86214. */
  86215. 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;
  86216. /**
  86217. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86218. *
  86219. * @param renderingGroupId The rendering group id corresponding to its index
  86220. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86221. * @param depth Automatically clears depth between groups if true and autoClear is true.
  86222. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  86223. */
  86224. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  86225. /**
  86226. * Gets the current auto clear configuration for one rendering group of the rendering
  86227. * manager.
  86228. * @param index the rendering group index to get the information for
  86229. * @returns The auto clear setup for the requested rendering group
  86230. */
  86231. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  86232. }
  86233. }
  86234. declare module BABYLON {
  86235. /**
  86236. * This Helps creating a texture that will be created from a camera in your scene.
  86237. * It is basically a dynamic texture that could be used to create special effects for instance.
  86238. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  86239. */
  86240. export class RenderTargetTexture extends Texture {
  86241. isCube: boolean;
  86242. /**
  86243. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  86244. */
  86245. static readonly REFRESHRATE_RENDER_ONCE: number;
  86246. /**
  86247. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  86248. */
  86249. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  86250. /**
  86251. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  86252. * the central point of your effect and can save a lot of performances.
  86253. */
  86254. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  86255. /**
  86256. * Use this predicate to dynamically define the list of mesh you want to render.
  86257. * If set, the renderList property will be overwritten.
  86258. */
  86259. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  86260. private _renderList;
  86261. /**
  86262. * Use this list to define the list of mesh you want to render.
  86263. */
  86264. renderList: Nullable<Array<AbstractMesh>>;
  86265. private _hookArray;
  86266. /**
  86267. * Define if particles should be rendered in your texture.
  86268. */
  86269. renderParticles: boolean;
  86270. /**
  86271. * Define if sprites should be rendered in your texture.
  86272. */
  86273. renderSprites: boolean;
  86274. /**
  86275. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  86276. */
  86277. coordinatesMode: number;
  86278. /**
  86279. * Define the camera used to render the texture.
  86280. */
  86281. activeCamera: Nullable<Camera>;
  86282. /**
  86283. * Override the render function of the texture with your own one.
  86284. */
  86285. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  86286. /**
  86287. * Define if camera post processes should be use while rendering the texture.
  86288. */
  86289. useCameraPostProcesses: boolean;
  86290. /**
  86291. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  86292. */
  86293. ignoreCameraViewport: boolean;
  86294. private _postProcessManager;
  86295. private _postProcesses;
  86296. private _resizeObserver;
  86297. /**
  86298. * An event triggered when the texture is unbind.
  86299. */
  86300. onBeforeBindObservable: Observable<RenderTargetTexture>;
  86301. /**
  86302. * An event triggered when the texture is unbind.
  86303. */
  86304. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  86305. private _onAfterUnbindObserver;
  86306. /**
  86307. * Set a after unbind callback in the texture.
  86308. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  86309. */
  86310. onAfterUnbind: () => void;
  86311. /**
  86312. * An event triggered before rendering the texture
  86313. */
  86314. onBeforeRenderObservable: Observable<number>;
  86315. private _onBeforeRenderObserver;
  86316. /**
  86317. * Set a before render callback in the texture.
  86318. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  86319. */
  86320. onBeforeRender: (faceIndex: number) => void;
  86321. /**
  86322. * An event triggered after rendering the texture
  86323. */
  86324. onAfterRenderObservable: Observable<number>;
  86325. private _onAfterRenderObserver;
  86326. /**
  86327. * Set a after render callback in the texture.
  86328. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  86329. */
  86330. onAfterRender: (faceIndex: number) => void;
  86331. /**
  86332. * An event triggered after the texture clear
  86333. */
  86334. onClearObservable: Observable<Engine>;
  86335. private _onClearObserver;
  86336. /**
  86337. * Set a clear callback in the texture.
  86338. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  86339. */
  86340. onClear: (Engine: Engine) => void;
  86341. /**
  86342. * An event triggered when the texture is resized.
  86343. */
  86344. onResizeObservable: Observable<RenderTargetTexture>;
  86345. /**
  86346. * Define the clear color of the Render Target if it should be different from the scene.
  86347. */
  86348. clearColor: Color4;
  86349. protected _size: number | {
  86350. width: number;
  86351. height: number;
  86352. };
  86353. protected _initialSizeParameter: number | {
  86354. width: number;
  86355. height: number;
  86356. } | {
  86357. ratio: number;
  86358. };
  86359. protected _sizeRatio: Nullable<number>;
  86360. /** @hidden */
  86361. _generateMipMaps: boolean;
  86362. protected _renderingManager: RenderingManager;
  86363. /** @hidden */
  86364. _waitingRenderList: string[];
  86365. protected _doNotChangeAspectRatio: boolean;
  86366. protected _currentRefreshId: number;
  86367. protected _refreshRate: number;
  86368. protected _textureMatrix: Matrix;
  86369. protected _samples: number;
  86370. protected _renderTargetOptions: RenderTargetCreationOptions;
  86371. /**
  86372. * Gets render target creation options that were used.
  86373. */
  86374. readonly renderTargetOptions: RenderTargetCreationOptions;
  86375. protected _engine: Engine;
  86376. protected _onRatioRescale(): void;
  86377. /**
  86378. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  86379. * It must define where the camera used to render the texture is set
  86380. */
  86381. boundingBoxPosition: Vector3;
  86382. private _boundingBoxSize;
  86383. /**
  86384. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  86385. * When defined, the cubemap will switch to local mode
  86386. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86387. * @example https://www.babylonjs-playground.com/#RNASML
  86388. */
  86389. boundingBoxSize: Vector3;
  86390. /**
  86391. * In case the RTT has been created with a depth texture, get the associated
  86392. * depth texture.
  86393. * Otherwise, return null.
  86394. */
  86395. depthStencilTexture: Nullable<InternalTexture>;
  86396. /**
  86397. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  86398. * or used a shadow, depth texture...
  86399. * @param name The friendly name of the texture
  86400. * @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)
  86401. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  86402. * @param generateMipMaps True if mip maps need to be generated after render.
  86403. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  86404. * @param type The type of the buffer in the RTT (int, half float, float...)
  86405. * @param isCube True if a cube texture needs to be created
  86406. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  86407. * @param generateDepthBuffer True to generate a depth buffer
  86408. * @param generateStencilBuffer True to generate a stencil buffer
  86409. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  86410. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  86411. * @param delayAllocation if the texture allocation should be delayed (default: false)
  86412. */
  86413. constructor(name: string, size: number | {
  86414. width: number;
  86415. height: number;
  86416. } | {
  86417. ratio: number;
  86418. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  86419. /**
  86420. * Creates a depth stencil texture.
  86421. * This is only available in WebGL 2 or with the depth texture extension available.
  86422. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  86423. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  86424. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  86425. */
  86426. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  86427. private _processSizeParameter;
  86428. /**
  86429. * Define the number of samples to use in case of MSAA.
  86430. * It defaults to one meaning no MSAA has been enabled.
  86431. */
  86432. samples: number;
  86433. /**
  86434. * Resets the refresh counter of the texture and start bak from scratch.
  86435. * Could be useful to regenerate the texture if it is setup to render only once.
  86436. */
  86437. resetRefreshCounter(): void;
  86438. /**
  86439. * Define the refresh rate of the texture or the rendering frequency.
  86440. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  86441. */
  86442. refreshRate: number;
  86443. /**
  86444. * Adds a post process to the render target rendering passes.
  86445. * @param postProcess define the post process to add
  86446. */
  86447. addPostProcess(postProcess: PostProcess): void;
  86448. /**
  86449. * Clear all the post processes attached to the render target
  86450. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  86451. */
  86452. clearPostProcesses(dispose?: boolean): void;
  86453. /**
  86454. * Remove one of the post process from the list of attached post processes to the texture
  86455. * @param postProcess define the post process to remove from the list
  86456. */
  86457. removePostProcess(postProcess: PostProcess): void;
  86458. /** @hidden */
  86459. _shouldRender(): boolean;
  86460. /**
  86461. * Gets the actual render size of the texture.
  86462. * @returns the width of the render size
  86463. */
  86464. getRenderSize(): number;
  86465. /**
  86466. * Gets the actual render width of the texture.
  86467. * @returns the width of the render size
  86468. */
  86469. getRenderWidth(): number;
  86470. /**
  86471. * Gets the actual render height of the texture.
  86472. * @returns the height of the render size
  86473. */
  86474. getRenderHeight(): number;
  86475. /**
  86476. * Get if the texture can be rescaled or not.
  86477. */
  86478. readonly canRescale: boolean;
  86479. /**
  86480. * Resize the texture using a ratio.
  86481. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  86482. */
  86483. scale(ratio: number): void;
  86484. /**
  86485. * Get the texture reflection matrix used to rotate/transform the reflection.
  86486. * @returns the reflection matrix
  86487. */
  86488. getReflectionTextureMatrix(): Matrix;
  86489. /**
  86490. * Resize the texture to a new desired size.
  86491. * Be carrefull as it will recreate all the data in the new texture.
  86492. * @param size Define the new size. It can be:
  86493. * - a number for squared texture,
  86494. * - an object containing { width: number, height: number }
  86495. * - or an object containing a ratio { ratio: number }
  86496. */
  86497. resize(size: number | {
  86498. width: number;
  86499. height: number;
  86500. } | {
  86501. ratio: number;
  86502. }): void;
  86503. /**
  86504. * Renders all the objects from the render list into the texture.
  86505. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  86506. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  86507. */
  86508. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  86509. private _bestReflectionRenderTargetDimension;
  86510. /**
  86511. * @hidden
  86512. * @param faceIndex face index to bind to if this is a cubetexture
  86513. */
  86514. _bindFrameBuffer(faceIndex?: number): void;
  86515. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  86516. private renderToTarget;
  86517. /**
  86518. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86519. * This allowed control for front to back rendering or reversly depending of the special needs.
  86520. *
  86521. * @param renderingGroupId The rendering group id corresponding to its index
  86522. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86523. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86524. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86525. */
  86526. 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;
  86527. /**
  86528. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86529. *
  86530. * @param renderingGroupId The rendering group id corresponding to its index
  86531. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86532. */
  86533. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  86534. /**
  86535. * Clones the texture.
  86536. * @returns the cloned texture
  86537. */
  86538. clone(): RenderTargetTexture;
  86539. /**
  86540. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86541. * @returns The JSON representation of the texture
  86542. */
  86543. serialize(): any;
  86544. /**
  86545. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  86546. */
  86547. disposeFramebufferObjects(): void;
  86548. /**
  86549. * Dispose the texture and release its associated resources.
  86550. */
  86551. dispose(): void;
  86552. /** @hidden */
  86553. _rebuild(): void;
  86554. /**
  86555. * Clear the info related to rendering groups preventing retention point in material dispose.
  86556. */
  86557. freeRenderingGroups(): void;
  86558. /**
  86559. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  86560. * @returns the view count
  86561. */
  86562. getViewCount(): number;
  86563. }
  86564. }
  86565. declare module BABYLON {
  86566. /**
  86567. * Base class for the main features of a material in Babylon.js
  86568. */
  86569. export class Material implements IAnimatable {
  86570. /**
  86571. * Returns the triangle fill mode
  86572. */
  86573. static readonly TriangleFillMode: number;
  86574. /**
  86575. * Returns the wireframe mode
  86576. */
  86577. static readonly WireFrameFillMode: number;
  86578. /**
  86579. * Returns the point fill mode
  86580. */
  86581. static readonly PointFillMode: number;
  86582. /**
  86583. * Returns the point list draw mode
  86584. */
  86585. static readonly PointListDrawMode: number;
  86586. /**
  86587. * Returns the line list draw mode
  86588. */
  86589. static readonly LineListDrawMode: number;
  86590. /**
  86591. * Returns the line loop draw mode
  86592. */
  86593. static readonly LineLoopDrawMode: number;
  86594. /**
  86595. * Returns the line strip draw mode
  86596. */
  86597. static readonly LineStripDrawMode: number;
  86598. /**
  86599. * Returns the triangle strip draw mode
  86600. */
  86601. static readonly TriangleStripDrawMode: number;
  86602. /**
  86603. * Returns the triangle fan draw mode
  86604. */
  86605. static readonly TriangleFanDrawMode: number;
  86606. /**
  86607. * Stores the clock-wise side orientation
  86608. */
  86609. static readonly ClockWiseSideOrientation: number;
  86610. /**
  86611. * Stores the counter clock-wise side orientation
  86612. */
  86613. static readonly CounterClockWiseSideOrientation: number;
  86614. /**
  86615. * The dirty texture flag value
  86616. */
  86617. static readonly TextureDirtyFlag: number;
  86618. /**
  86619. * The dirty light flag value
  86620. */
  86621. static readonly LightDirtyFlag: number;
  86622. /**
  86623. * The dirty fresnel flag value
  86624. */
  86625. static readonly FresnelDirtyFlag: number;
  86626. /**
  86627. * The dirty attribute flag value
  86628. */
  86629. static readonly AttributesDirtyFlag: number;
  86630. /**
  86631. * The dirty misc flag value
  86632. */
  86633. static readonly MiscDirtyFlag: number;
  86634. /**
  86635. * The all dirty flag value
  86636. */
  86637. static readonly AllDirtyFlag: number;
  86638. /**
  86639. * The ID of the material
  86640. */
  86641. id: string;
  86642. /**
  86643. * Gets or sets the unique id of the material
  86644. */
  86645. uniqueId: number;
  86646. /**
  86647. * The name of the material
  86648. */
  86649. name: string;
  86650. /**
  86651. * Gets or sets user defined metadata
  86652. */
  86653. metadata: any;
  86654. /**
  86655. * For internal use only. Please do not use.
  86656. */
  86657. reservedDataStore: any;
  86658. /**
  86659. * Specifies if the ready state should be checked on each call
  86660. */
  86661. checkReadyOnEveryCall: boolean;
  86662. /**
  86663. * Specifies if the ready state should be checked once
  86664. */
  86665. checkReadyOnlyOnce: boolean;
  86666. /**
  86667. * The state of the material
  86668. */
  86669. state: string;
  86670. /**
  86671. * The alpha value of the material
  86672. */
  86673. protected _alpha: number;
  86674. /**
  86675. * List of inspectable custom properties (used by the Inspector)
  86676. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86677. */
  86678. inspectableCustomProperties: IInspectable[];
  86679. /**
  86680. * Sets the alpha value of the material
  86681. */
  86682. /**
  86683. * Gets the alpha value of the material
  86684. */
  86685. alpha: number;
  86686. /**
  86687. * Specifies if back face culling is enabled
  86688. */
  86689. protected _backFaceCulling: boolean;
  86690. /**
  86691. * Sets the back-face culling state
  86692. */
  86693. /**
  86694. * Gets the back-face culling state
  86695. */
  86696. backFaceCulling: boolean;
  86697. /**
  86698. * Stores the value for side orientation
  86699. */
  86700. sideOrientation: number;
  86701. /**
  86702. * Callback triggered when the material is compiled
  86703. */
  86704. onCompiled: Nullable<(effect: Effect) => void>;
  86705. /**
  86706. * Callback triggered when an error occurs
  86707. */
  86708. onError: Nullable<(effect: Effect, errors: string) => void>;
  86709. /**
  86710. * Callback triggered to get the render target textures
  86711. */
  86712. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  86713. /**
  86714. * Gets a boolean indicating that current material needs to register RTT
  86715. */
  86716. readonly hasRenderTargetTextures: boolean;
  86717. /**
  86718. * Specifies if the material should be serialized
  86719. */
  86720. doNotSerialize: boolean;
  86721. /**
  86722. * @hidden
  86723. */
  86724. _storeEffectOnSubMeshes: boolean;
  86725. /**
  86726. * Stores the animations for the material
  86727. */
  86728. animations: Nullable<Array<Animation>>;
  86729. /**
  86730. * An event triggered when the material is disposed
  86731. */
  86732. onDisposeObservable: Observable<Material>;
  86733. /**
  86734. * An observer which watches for dispose events
  86735. */
  86736. private _onDisposeObserver;
  86737. private _onUnBindObservable;
  86738. /**
  86739. * Called during a dispose event
  86740. */
  86741. onDispose: () => void;
  86742. private _onBindObservable;
  86743. /**
  86744. * An event triggered when the material is bound
  86745. */
  86746. readonly onBindObservable: Observable<AbstractMesh>;
  86747. /**
  86748. * An observer which watches for bind events
  86749. */
  86750. private _onBindObserver;
  86751. /**
  86752. * Called during a bind event
  86753. */
  86754. onBind: (Mesh: AbstractMesh) => void;
  86755. /**
  86756. * An event triggered when the material is unbound
  86757. */
  86758. readonly onUnBindObservable: Observable<Material>;
  86759. /**
  86760. * Stores the value of the alpha mode
  86761. */
  86762. private _alphaMode;
  86763. /**
  86764. * Sets the value of the alpha mode.
  86765. *
  86766. * | Value | Type | Description |
  86767. * | --- | --- | --- |
  86768. * | 0 | ALPHA_DISABLE | |
  86769. * | 1 | ALPHA_ADD | |
  86770. * | 2 | ALPHA_COMBINE | |
  86771. * | 3 | ALPHA_SUBTRACT | |
  86772. * | 4 | ALPHA_MULTIPLY | |
  86773. * | 5 | ALPHA_MAXIMIZED | |
  86774. * | 6 | ALPHA_ONEONE | |
  86775. * | 7 | ALPHA_PREMULTIPLIED | |
  86776. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  86777. * | 9 | ALPHA_INTERPOLATE | |
  86778. * | 10 | ALPHA_SCREENMODE | |
  86779. *
  86780. */
  86781. /**
  86782. * Gets the value of the alpha mode
  86783. */
  86784. alphaMode: number;
  86785. /**
  86786. * Stores the state of the need depth pre-pass value
  86787. */
  86788. private _needDepthPrePass;
  86789. /**
  86790. * Sets the need depth pre-pass value
  86791. */
  86792. /**
  86793. * Gets the depth pre-pass value
  86794. */
  86795. needDepthPrePass: boolean;
  86796. /**
  86797. * Specifies if depth writing should be disabled
  86798. */
  86799. disableDepthWrite: boolean;
  86800. /**
  86801. * Specifies if depth writing should be forced
  86802. */
  86803. forceDepthWrite: boolean;
  86804. /**
  86805. * Specifies if there should be a separate pass for culling
  86806. */
  86807. separateCullingPass: boolean;
  86808. /**
  86809. * Stores the state specifing if fog should be enabled
  86810. */
  86811. private _fogEnabled;
  86812. /**
  86813. * Sets the state for enabling fog
  86814. */
  86815. /**
  86816. * Gets the value of the fog enabled state
  86817. */
  86818. fogEnabled: boolean;
  86819. /**
  86820. * Stores the size of points
  86821. */
  86822. pointSize: number;
  86823. /**
  86824. * Stores the z offset value
  86825. */
  86826. zOffset: number;
  86827. /**
  86828. * Gets a value specifying if wireframe mode is enabled
  86829. */
  86830. /**
  86831. * Sets the state of wireframe mode
  86832. */
  86833. wireframe: boolean;
  86834. /**
  86835. * Gets the value specifying if point clouds are enabled
  86836. */
  86837. /**
  86838. * Sets the state of point cloud mode
  86839. */
  86840. pointsCloud: boolean;
  86841. /**
  86842. * Gets the material fill mode
  86843. */
  86844. /**
  86845. * Sets the material fill mode
  86846. */
  86847. fillMode: number;
  86848. /**
  86849. * @hidden
  86850. * Stores the effects for the material
  86851. */
  86852. _effect: Nullable<Effect>;
  86853. /**
  86854. * @hidden
  86855. * Specifies if the material was previously ready
  86856. */
  86857. _wasPreviouslyReady: boolean;
  86858. /**
  86859. * Specifies if uniform buffers should be used
  86860. */
  86861. private _useUBO;
  86862. /**
  86863. * Stores a reference to the scene
  86864. */
  86865. private _scene;
  86866. /**
  86867. * Stores the fill mode state
  86868. */
  86869. private _fillMode;
  86870. /**
  86871. * Specifies if the depth write state should be cached
  86872. */
  86873. private _cachedDepthWriteState;
  86874. /**
  86875. * Stores the uniform buffer
  86876. */
  86877. protected _uniformBuffer: UniformBuffer;
  86878. /** @hidden */
  86879. _indexInSceneMaterialArray: number;
  86880. /** @hidden */
  86881. meshMap: Nullable<{
  86882. [id: string]: AbstractMesh | undefined;
  86883. }>;
  86884. /**
  86885. * Creates a material instance
  86886. * @param name defines the name of the material
  86887. * @param scene defines the scene to reference
  86888. * @param doNotAdd specifies if the material should be added to the scene
  86889. */
  86890. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  86891. /**
  86892. * Returns a string representation of the current material
  86893. * @param fullDetails defines a boolean indicating which levels of logging is desired
  86894. * @returns a string with material information
  86895. */
  86896. toString(fullDetails?: boolean): string;
  86897. /**
  86898. * Gets the class name of the material
  86899. * @returns a string with the class name of the material
  86900. */
  86901. getClassName(): string;
  86902. /**
  86903. * Specifies if updates for the material been locked
  86904. */
  86905. readonly isFrozen: boolean;
  86906. /**
  86907. * Locks updates for the material
  86908. */
  86909. freeze(): void;
  86910. /**
  86911. * Unlocks updates for the material
  86912. */
  86913. unfreeze(): void;
  86914. /**
  86915. * Specifies if the material is ready to be used
  86916. * @param mesh defines the mesh to check
  86917. * @param useInstances specifies if instances should be used
  86918. * @returns a boolean indicating if the material is ready to be used
  86919. */
  86920. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86921. /**
  86922. * Specifies that the submesh is ready to be used
  86923. * @param mesh defines the mesh to check
  86924. * @param subMesh defines which submesh to check
  86925. * @param useInstances specifies that instances should be used
  86926. * @returns a boolean indicating that the submesh is ready or not
  86927. */
  86928. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86929. /**
  86930. * Returns the material effect
  86931. * @returns the effect associated with the material
  86932. */
  86933. getEffect(): Nullable<Effect>;
  86934. /**
  86935. * Returns the current scene
  86936. * @returns a Scene
  86937. */
  86938. getScene(): Scene;
  86939. /**
  86940. * Specifies if the material will require alpha blending
  86941. * @returns a boolean specifying if alpha blending is needed
  86942. */
  86943. needAlphaBlending(): boolean;
  86944. /**
  86945. * Specifies if the mesh will require alpha blending
  86946. * @param mesh defines the mesh to check
  86947. * @returns a boolean specifying if alpha blending is needed for the mesh
  86948. */
  86949. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  86950. /**
  86951. * Specifies if this material should be rendered in alpha test mode
  86952. * @returns a boolean specifying if an alpha test is needed.
  86953. */
  86954. needAlphaTesting(): boolean;
  86955. /**
  86956. * Gets the texture used for the alpha test
  86957. * @returns the texture to use for alpha testing
  86958. */
  86959. getAlphaTestTexture(): Nullable<BaseTexture>;
  86960. /**
  86961. * Marks the material to indicate that it needs to be re-calculated
  86962. */
  86963. markDirty(): void;
  86964. /** @hidden */
  86965. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  86966. /**
  86967. * Binds the material to the mesh
  86968. * @param world defines the world transformation matrix
  86969. * @param mesh defines the mesh to bind the material to
  86970. */
  86971. bind(world: Matrix, mesh?: Mesh): void;
  86972. /**
  86973. * Binds the submesh to the material
  86974. * @param world defines the world transformation matrix
  86975. * @param mesh defines the mesh containing the submesh
  86976. * @param subMesh defines the submesh to bind the material to
  86977. */
  86978. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  86979. /**
  86980. * Binds the world matrix to the material
  86981. * @param world defines the world transformation matrix
  86982. */
  86983. bindOnlyWorldMatrix(world: Matrix): void;
  86984. /**
  86985. * Binds the scene's uniform buffer to the effect.
  86986. * @param effect defines the effect to bind to the scene uniform buffer
  86987. * @param sceneUbo defines the uniform buffer storing scene data
  86988. */
  86989. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  86990. /**
  86991. * Binds the view matrix to the effect
  86992. * @param effect defines the effect to bind the view matrix to
  86993. */
  86994. bindView(effect: Effect): void;
  86995. /**
  86996. * Binds the view projection matrix to the effect
  86997. * @param effect defines the effect to bind the view projection matrix to
  86998. */
  86999. bindViewProjection(effect: Effect): void;
  87000. /**
  87001. * Specifies if material alpha testing should be turned on for the mesh
  87002. * @param mesh defines the mesh to check
  87003. */
  87004. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  87005. /**
  87006. * Processes to execute after binding the material to a mesh
  87007. * @param mesh defines the rendered mesh
  87008. */
  87009. protected _afterBind(mesh?: Mesh): void;
  87010. /**
  87011. * Unbinds the material from the mesh
  87012. */
  87013. unbind(): void;
  87014. /**
  87015. * Gets the active textures from the material
  87016. * @returns an array of textures
  87017. */
  87018. getActiveTextures(): BaseTexture[];
  87019. /**
  87020. * Specifies if the material uses a texture
  87021. * @param texture defines the texture to check against the material
  87022. * @returns a boolean specifying if the material uses the texture
  87023. */
  87024. hasTexture(texture: BaseTexture): boolean;
  87025. /**
  87026. * Makes a duplicate of the material, and gives it a new name
  87027. * @param name defines the new name for the duplicated material
  87028. * @returns the cloned material
  87029. */
  87030. clone(name: string): Nullable<Material>;
  87031. /**
  87032. * Gets the meshes bound to the material
  87033. * @returns an array of meshes bound to the material
  87034. */
  87035. getBindedMeshes(): AbstractMesh[];
  87036. /**
  87037. * Force shader compilation
  87038. * @param mesh defines the mesh associated with this material
  87039. * @param onCompiled defines a function to execute once the material is compiled
  87040. * @param options defines the options to configure the compilation
  87041. */
  87042. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  87043. clipPlane: boolean;
  87044. }>): void;
  87045. /**
  87046. * Force shader compilation
  87047. * @param mesh defines the mesh that will use this material
  87048. * @param options defines additional options for compiling the shaders
  87049. * @returns a promise that resolves when the compilation completes
  87050. */
  87051. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  87052. clipPlane: boolean;
  87053. }>): Promise<void>;
  87054. private static readonly _AllDirtyCallBack;
  87055. private static readonly _ImageProcessingDirtyCallBack;
  87056. private static readonly _TextureDirtyCallBack;
  87057. private static readonly _FresnelDirtyCallBack;
  87058. private static readonly _MiscDirtyCallBack;
  87059. private static readonly _LightsDirtyCallBack;
  87060. private static readonly _AttributeDirtyCallBack;
  87061. private static _FresnelAndMiscDirtyCallBack;
  87062. private static _TextureAndMiscDirtyCallBack;
  87063. private static readonly _DirtyCallbackArray;
  87064. private static readonly _RunDirtyCallBacks;
  87065. /**
  87066. * Marks a define in the material to indicate that it needs to be re-computed
  87067. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  87068. */
  87069. markAsDirty(flag: number): void;
  87070. /**
  87071. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  87072. * @param func defines a function which checks material defines against the submeshes
  87073. */
  87074. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  87075. /**
  87076. * Indicates that we need to re-calculated for all submeshes
  87077. */
  87078. protected _markAllSubMeshesAsAllDirty(): void;
  87079. /**
  87080. * Indicates that image processing needs to be re-calculated for all submeshes
  87081. */
  87082. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  87083. /**
  87084. * Indicates that textures need to be re-calculated for all submeshes
  87085. */
  87086. protected _markAllSubMeshesAsTexturesDirty(): void;
  87087. /**
  87088. * Indicates that fresnel needs to be re-calculated for all submeshes
  87089. */
  87090. protected _markAllSubMeshesAsFresnelDirty(): void;
  87091. /**
  87092. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  87093. */
  87094. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  87095. /**
  87096. * Indicates that lights need to be re-calculated for all submeshes
  87097. */
  87098. protected _markAllSubMeshesAsLightsDirty(): void;
  87099. /**
  87100. * Indicates that attributes need to be re-calculated for all submeshes
  87101. */
  87102. protected _markAllSubMeshesAsAttributesDirty(): void;
  87103. /**
  87104. * Indicates that misc needs to be re-calculated for all submeshes
  87105. */
  87106. protected _markAllSubMeshesAsMiscDirty(): void;
  87107. /**
  87108. * Indicates that textures and misc need to be re-calculated for all submeshes
  87109. */
  87110. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  87111. /**
  87112. * Disposes the material
  87113. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87114. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87115. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87116. */
  87117. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87118. /** @hidden */
  87119. private releaseVertexArrayObject;
  87120. /**
  87121. * Serializes this material
  87122. * @returns the serialized material object
  87123. */
  87124. serialize(): any;
  87125. /**
  87126. * Creates a material from parsed material data
  87127. * @param parsedMaterial defines parsed material data
  87128. * @param scene defines the hosting scene
  87129. * @param rootUrl defines the root URL to use to load textures
  87130. * @returns a new material
  87131. */
  87132. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  87133. }
  87134. }
  87135. declare module BABYLON {
  87136. /**
  87137. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87138. * separate meshes. This can be use to improve performances.
  87139. * @see http://doc.babylonjs.com/how_to/multi_materials
  87140. */
  87141. export class MultiMaterial extends Material {
  87142. private _subMaterials;
  87143. /**
  87144. * Gets or Sets the list of Materials used within the multi material.
  87145. * They need to be ordered according to the submeshes order in the associated mesh
  87146. */
  87147. subMaterials: Nullable<Material>[];
  87148. /**
  87149. * Function used to align with Node.getChildren()
  87150. * @returns the list of Materials used within the multi material
  87151. */
  87152. getChildren(): Nullable<Material>[];
  87153. /**
  87154. * Instantiates a new Multi Material
  87155. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87156. * separate meshes. This can be use to improve performances.
  87157. * @see http://doc.babylonjs.com/how_to/multi_materials
  87158. * @param name Define the name in the scene
  87159. * @param scene Define the scene the material belongs to
  87160. */
  87161. constructor(name: string, scene: Scene);
  87162. private _hookArray;
  87163. /**
  87164. * Get one of the submaterial by its index in the submaterials array
  87165. * @param index The index to look the sub material at
  87166. * @returns The Material if the index has been defined
  87167. */
  87168. getSubMaterial(index: number): Nullable<Material>;
  87169. /**
  87170. * Get the list of active textures for the whole sub materials list.
  87171. * @returns All the textures that will be used during the rendering
  87172. */
  87173. getActiveTextures(): BaseTexture[];
  87174. /**
  87175. * Gets the current class name of the material e.g. "MultiMaterial"
  87176. * Mainly use in serialization.
  87177. * @returns the class name
  87178. */
  87179. getClassName(): string;
  87180. /**
  87181. * Checks if the material is ready to render the requested sub mesh
  87182. * @param mesh Define the mesh the submesh belongs to
  87183. * @param subMesh Define the sub mesh to look readyness for
  87184. * @param useInstances Define whether or not the material is used with instances
  87185. * @returns true if ready, otherwise false
  87186. */
  87187. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87188. /**
  87189. * Clones the current material and its related sub materials
  87190. * @param name Define the name of the newly cloned material
  87191. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  87192. * @returns the cloned material
  87193. */
  87194. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  87195. /**
  87196. * Serializes the materials into a JSON representation.
  87197. * @returns the JSON representation
  87198. */
  87199. serialize(): any;
  87200. /**
  87201. * Dispose the material and release its associated resources
  87202. * @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)
  87203. * @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)
  87204. * @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)
  87205. */
  87206. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  87207. /**
  87208. * Creates a MultiMaterial from parsed MultiMaterial data.
  87209. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  87210. * @param scene defines the hosting scene
  87211. * @returns a new MultiMaterial
  87212. */
  87213. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  87214. }
  87215. }
  87216. declare module BABYLON {
  87217. /**
  87218. * Base class for submeshes
  87219. */
  87220. export class BaseSubMesh {
  87221. /** @hidden */
  87222. _materialDefines: Nullable<MaterialDefines>;
  87223. /** @hidden */
  87224. _materialEffect: Nullable<Effect>;
  87225. /**
  87226. * Gets associated effect
  87227. */
  87228. readonly effect: Nullable<Effect>;
  87229. /**
  87230. * Sets associated effect (effect used to render this submesh)
  87231. * @param effect defines the effect to associate with
  87232. * @param defines defines the set of defines used to compile this effect
  87233. */
  87234. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  87235. }
  87236. /**
  87237. * Defines a subdivision inside a mesh
  87238. */
  87239. export class SubMesh extends BaseSubMesh implements ICullable {
  87240. /** the material index to use */
  87241. materialIndex: number;
  87242. /** vertex index start */
  87243. verticesStart: number;
  87244. /** vertices count */
  87245. verticesCount: number;
  87246. /** index start */
  87247. indexStart: number;
  87248. /** indices count */
  87249. indexCount: number;
  87250. /** @hidden */
  87251. _linesIndexCount: number;
  87252. private _mesh;
  87253. private _renderingMesh;
  87254. private _boundingInfo;
  87255. private _linesIndexBuffer;
  87256. /** @hidden */
  87257. _lastColliderWorldVertices: Nullable<Vector3[]>;
  87258. /** @hidden */
  87259. _trianglePlanes: Plane[];
  87260. /** @hidden */
  87261. _lastColliderTransformMatrix: Nullable<Matrix>;
  87262. /** @hidden */
  87263. _renderId: number;
  87264. /** @hidden */
  87265. _alphaIndex: number;
  87266. /** @hidden */
  87267. _distanceToCamera: number;
  87268. /** @hidden */
  87269. _id: number;
  87270. private _currentMaterial;
  87271. /**
  87272. * Add a new submesh to a mesh
  87273. * @param materialIndex defines the material index to use
  87274. * @param verticesStart defines vertex index start
  87275. * @param verticesCount defines vertices count
  87276. * @param indexStart defines index start
  87277. * @param indexCount defines indices count
  87278. * @param mesh defines the parent mesh
  87279. * @param renderingMesh defines an optional rendering mesh
  87280. * @param createBoundingBox defines if bounding box should be created for this submesh
  87281. * @returns the new submesh
  87282. */
  87283. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  87284. /**
  87285. * Creates a new submesh
  87286. * @param materialIndex defines the material index to use
  87287. * @param verticesStart defines vertex index start
  87288. * @param verticesCount defines vertices count
  87289. * @param indexStart defines index start
  87290. * @param indexCount defines indices count
  87291. * @param mesh defines the parent mesh
  87292. * @param renderingMesh defines an optional rendering mesh
  87293. * @param createBoundingBox defines if bounding box should be created for this submesh
  87294. */
  87295. constructor(
  87296. /** the material index to use */
  87297. materialIndex: number,
  87298. /** vertex index start */
  87299. verticesStart: number,
  87300. /** vertices count */
  87301. verticesCount: number,
  87302. /** index start */
  87303. indexStart: number,
  87304. /** indices count */
  87305. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  87306. /**
  87307. * Returns true if this submesh covers the entire parent mesh
  87308. * @ignorenaming
  87309. */
  87310. readonly IsGlobal: boolean;
  87311. /**
  87312. * Returns the submesh BoudingInfo object
  87313. * @returns current bounding info (or mesh's one if the submesh is global)
  87314. */
  87315. getBoundingInfo(): BoundingInfo;
  87316. /**
  87317. * Sets the submesh BoundingInfo
  87318. * @param boundingInfo defines the new bounding info to use
  87319. * @returns the SubMesh
  87320. */
  87321. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  87322. /**
  87323. * Returns the mesh of the current submesh
  87324. * @return the parent mesh
  87325. */
  87326. getMesh(): AbstractMesh;
  87327. /**
  87328. * Returns the rendering mesh of the submesh
  87329. * @returns the rendering mesh (could be different from parent mesh)
  87330. */
  87331. getRenderingMesh(): Mesh;
  87332. /**
  87333. * Returns the submesh material
  87334. * @returns null or the current material
  87335. */
  87336. getMaterial(): Nullable<Material>;
  87337. /**
  87338. * Sets a new updated BoundingInfo object to the submesh
  87339. * @param data defines an optional position array to use to determine the bounding info
  87340. * @returns the SubMesh
  87341. */
  87342. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  87343. /** @hidden */
  87344. _checkCollision(collider: Collider): boolean;
  87345. /**
  87346. * Updates the submesh BoundingInfo
  87347. * @param world defines the world matrix to use to update the bounding info
  87348. * @returns the submesh
  87349. */
  87350. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  87351. /**
  87352. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  87353. * @param frustumPlanes defines the frustum planes
  87354. * @returns true if the submesh is intersecting with the frustum
  87355. */
  87356. isInFrustum(frustumPlanes: Plane[]): boolean;
  87357. /**
  87358. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  87359. * @param frustumPlanes defines the frustum planes
  87360. * @returns true if the submesh is inside the frustum
  87361. */
  87362. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87363. /**
  87364. * Renders the submesh
  87365. * @param enableAlphaMode defines if alpha needs to be used
  87366. * @returns the submesh
  87367. */
  87368. render(enableAlphaMode: boolean): SubMesh;
  87369. /**
  87370. * @hidden
  87371. */
  87372. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  87373. /**
  87374. * Checks if the submesh intersects with a ray
  87375. * @param ray defines the ray to test
  87376. * @returns true is the passed ray intersects the submesh bounding box
  87377. */
  87378. canIntersects(ray: Ray): boolean;
  87379. /**
  87380. * Intersects current submesh with a ray
  87381. * @param ray defines the ray to test
  87382. * @param positions defines mesh's positions array
  87383. * @param indices defines mesh's indices array
  87384. * @param fastCheck defines if only bounding info should be used
  87385. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87386. * @returns intersection info or null if no intersection
  87387. */
  87388. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  87389. /** @hidden */
  87390. private _intersectLines;
  87391. /** @hidden */
  87392. private _intersectUnIndexedLines;
  87393. /** @hidden */
  87394. private _intersectTriangles;
  87395. /** @hidden */
  87396. private _intersectUnIndexedTriangles;
  87397. /** @hidden */
  87398. _rebuild(): void;
  87399. /**
  87400. * Creates a new submesh from the passed mesh
  87401. * @param newMesh defines the new hosting mesh
  87402. * @param newRenderingMesh defines an optional rendering mesh
  87403. * @returns the new submesh
  87404. */
  87405. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  87406. /**
  87407. * Release associated resources
  87408. */
  87409. dispose(): void;
  87410. /**
  87411. * Gets the class name
  87412. * @returns the string "SubMesh".
  87413. */
  87414. getClassName(): string;
  87415. /**
  87416. * Creates a new submesh from indices data
  87417. * @param materialIndex the index of the main mesh material
  87418. * @param startIndex the index where to start the copy in the mesh indices array
  87419. * @param indexCount the number of indices to copy then from the startIndex
  87420. * @param mesh the main mesh to create the submesh from
  87421. * @param renderingMesh the optional rendering mesh
  87422. * @returns a new submesh
  87423. */
  87424. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  87425. }
  87426. }
  87427. declare module BABYLON {
  87428. /**
  87429. * Class used to represent data loading progression
  87430. */
  87431. export class SceneLoaderFlags {
  87432. private static _ForceFullSceneLoadingForIncremental;
  87433. private static _ShowLoadingScreen;
  87434. private static _CleanBoneMatrixWeights;
  87435. private static _loggingLevel;
  87436. /**
  87437. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  87438. */
  87439. static ForceFullSceneLoadingForIncremental: boolean;
  87440. /**
  87441. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  87442. */
  87443. static ShowLoadingScreen: boolean;
  87444. /**
  87445. * Defines the current logging level (while loading the scene)
  87446. * @ignorenaming
  87447. */
  87448. static loggingLevel: number;
  87449. /**
  87450. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  87451. */
  87452. static CleanBoneMatrixWeights: boolean;
  87453. }
  87454. }
  87455. declare module BABYLON {
  87456. /**
  87457. * Class used to store geometry data (vertex buffers + index buffer)
  87458. */
  87459. export class Geometry implements IGetSetVerticesData {
  87460. /**
  87461. * Gets or sets the ID of the geometry
  87462. */
  87463. id: string;
  87464. /**
  87465. * Gets or sets the unique ID of the geometry
  87466. */
  87467. uniqueId: number;
  87468. /**
  87469. * Gets the delay loading state of the geometry (none by default which means not delayed)
  87470. */
  87471. delayLoadState: number;
  87472. /**
  87473. * Gets the file containing the data to load when running in delay load state
  87474. */
  87475. delayLoadingFile: Nullable<string>;
  87476. /**
  87477. * Callback called when the geometry is updated
  87478. */
  87479. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  87480. private _scene;
  87481. private _engine;
  87482. private _meshes;
  87483. private _totalVertices;
  87484. /** @hidden */
  87485. _indices: IndicesArray;
  87486. /** @hidden */
  87487. _vertexBuffers: {
  87488. [key: string]: VertexBuffer;
  87489. };
  87490. private _isDisposed;
  87491. private _extend;
  87492. private _boundingBias;
  87493. /** @hidden */
  87494. _delayInfo: Array<string>;
  87495. private _indexBuffer;
  87496. private _indexBufferIsUpdatable;
  87497. /** @hidden */
  87498. _boundingInfo: Nullable<BoundingInfo>;
  87499. /** @hidden */
  87500. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  87501. /** @hidden */
  87502. _softwareSkinningFrameId: number;
  87503. private _vertexArrayObjects;
  87504. private _updatable;
  87505. /** @hidden */
  87506. _positions: Nullable<Vector3[]>;
  87507. /**
  87508. * 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
  87509. */
  87510. /**
  87511. * 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
  87512. */
  87513. boundingBias: Vector2;
  87514. /**
  87515. * Static function used to attach a new empty geometry to a mesh
  87516. * @param mesh defines the mesh to attach the geometry to
  87517. * @returns the new Geometry
  87518. */
  87519. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  87520. /**
  87521. * Creates a new geometry
  87522. * @param id defines the unique ID
  87523. * @param scene defines the hosting scene
  87524. * @param vertexData defines the VertexData used to get geometry data
  87525. * @param updatable defines if geometry must be updatable (false by default)
  87526. * @param mesh defines the mesh that will be associated with the geometry
  87527. */
  87528. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  87529. /**
  87530. * Gets the current extend of the geometry
  87531. */
  87532. readonly extend: {
  87533. minimum: Vector3;
  87534. maximum: Vector3;
  87535. };
  87536. /**
  87537. * Gets the hosting scene
  87538. * @returns the hosting Scene
  87539. */
  87540. getScene(): Scene;
  87541. /**
  87542. * Gets the hosting engine
  87543. * @returns the hosting Engine
  87544. */
  87545. getEngine(): Engine;
  87546. /**
  87547. * Defines if the geometry is ready to use
  87548. * @returns true if the geometry is ready to be used
  87549. */
  87550. isReady(): boolean;
  87551. /**
  87552. * Gets a value indicating that the geometry should not be serialized
  87553. */
  87554. readonly doNotSerialize: boolean;
  87555. /** @hidden */
  87556. _rebuild(): void;
  87557. /**
  87558. * Affects all geometry data in one call
  87559. * @param vertexData defines the geometry data
  87560. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  87561. */
  87562. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  87563. /**
  87564. * Set specific vertex data
  87565. * @param kind defines the data kind (Position, normal, etc...)
  87566. * @param data defines the vertex data to use
  87567. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87568. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87569. */
  87570. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  87571. /**
  87572. * Removes a specific vertex data
  87573. * @param kind defines the data kind (Position, normal, etc...)
  87574. */
  87575. removeVerticesData(kind: string): void;
  87576. /**
  87577. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  87578. * @param buffer defines the vertex buffer to use
  87579. * @param totalVertices defines the total number of vertices for position kind (could be null)
  87580. */
  87581. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  87582. /**
  87583. * Update a specific vertex buffer
  87584. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  87585. * It will do nothing if the buffer is not updatable
  87586. * @param kind defines the data kind (Position, normal, etc...)
  87587. * @param data defines the data to use
  87588. * @param offset defines the offset in the target buffer where to store the data
  87589. * @param useBytes set to true if the offset is in bytes
  87590. */
  87591. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  87592. /**
  87593. * Update a specific vertex buffer
  87594. * This function will create a new buffer if the current one is not updatable
  87595. * @param kind defines the data kind (Position, normal, etc...)
  87596. * @param data defines the data to use
  87597. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  87598. */
  87599. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  87600. private _updateBoundingInfo;
  87601. /** @hidden */
  87602. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  87603. /**
  87604. * Gets total number of vertices
  87605. * @returns the total number of vertices
  87606. */
  87607. getTotalVertices(): number;
  87608. /**
  87609. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87610. * @param kind defines the data kind (Position, normal, etc...)
  87611. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87612. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87613. * @returns a float array containing vertex data
  87614. */
  87615. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87616. /**
  87617. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  87618. * @param kind defines the data kind (Position, normal, etc...)
  87619. * @returns true if the vertex buffer with the specified kind is updatable
  87620. */
  87621. isVertexBufferUpdatable(kind: string): boolean;
  87622. /**
  87623. * Gets a specific vertex buffer
  87624. * @param kind defines the data kind (Position, normal, etc...)
  87625. * @returns a VertexBuffer
  87626. */
  87627. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87628. /**
  87629. * Returns all vertex buffers
  87630. * @return an object holding all vertex buffers indexed by kind
  87631. */
  87632. getVertexBuffers(): Nullable<{
  87633. [key: string]: VertexBuffer;
  87634. }>;
  87635. /**
  87636. * Gets a boolean indicating if specific vertex buffer is present
  87637. * @param kind defines the data kind (Position, normal, etc...)
  87638. * @returns true if data is present
  87639. */
  87640. isVerticesDataPresent(kind: string): boolean;
  87641. /**
  87642. * Gets a list of all attached data kinds (Position, normal, etc...)
  87643. * @returns a list of string containing all kinds
  87644. */
  87645. getVerticesDataKinds(): string[];
  87646. /**
  87647. * Update index buffer
  87648. * @param indices defines the indices to store in the index buffer
  87649. * @param offset defines the offset in the target buffer where to store the data
  87650. * @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)
  87651. */
  87652. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  87653. /**
  87654. * Creates a new index buffer
  87655. * @param indices defines the indices to store in the index buffer
  87656. * @param totalVertices defines the total number of vertices (could be null)
  87657. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87658. */
  87659. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  87660. /**
  87661. * Return the total number of indices
  87662. * @returns the total number of indices
  87663. */
  87664. getTotalIndices(): number;
  87665. /**
  87666. * Gets the index buffer array
  87667. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87668. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87669. * @returns the index buffer array
  87670. */
  87671. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87672. /**
  87673. * Gets the index buffer
  87674. * @return the index buffer
  87675. */
  87676. getIndexBuffer(): Nullable<DataBuffer>;
  87677. /** @hidden */
  87678. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  87679. /**
  87680. * Release the associated resources for a specific mesh
  87681. * @param mesh defines the source mesh
  87682. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  87683. */
  87684. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  87685. /**
  87686. * Apply current geometry to a given mesh
  87687. * @param mesh defines the mesh to apply geometry to
  87688. */
  87689. applyToMesh(mesh: Mesh): void;
  87690. private _updateExtend;
  87691. private _applyToMesh;
  87692. private notifyUpdate;
  87693. /**
  87694. * Load the geometry if it was flagged as delay loaded
  87695. * @param scene defines the hosting scene
  87696. * @param onLoaded defines a callback called when the geometry is loaded
  87697. */
  87698. load(scene: Scene, onLoaded?: () => void): void;
  87699. private _queueLoad;
  87700. /**
  87701. * Invert the geometry to move from a right handed system to a left handed one.
  87702. */
  87703. toLeftHanded(): void;
  87704. /** @hidden */
  87705. _resetPointsArrayCache(): void;
  87706. /** @hidden */
  87707. _generatePointsArray(): boolean;
  87708. /**
  87709. * Gets a value indicating if the geometry is disposed
  87710. * @returns true if the geometry was disposed
  87711. */
  87712. isDisposed(): boolean;
  87713. private _disposeVertexArrayObjects;
  87714. /**
  87715. * Free all associated resources
  87716. */
  87717. dispose(): void;
  87718. /**
  87719. * Clone the current geometry into a new geometry
  87720. * @param id defines the unique ID of the new geometry
  87721. * @returns a new geometry object
  87722. */
  87723. copy(id: string): Geometry;
  87724. /**
  87725. * Serialize the current geometry info (and not the vertices data) into a JSON object
  87726. * @return a JSON representation of the current geometry data (without the vertices data)
  87727. */
  87728. serialize(): any;
  87729. private toNumberArray;
  87730. /**
  87731. * Serialize all vertices data into a JSON oject
  87732. * @returns a JSON representation of the current geometry data
  87733. */
  87734. serializeVerticeData(): any;
  87735. /**
  87736. * Extracts a clone of a mesh geometry
  87737. * @param mesh defines the source mesh
  87738. * @param id defines the unique ID of the new geometry object
  87739. * @returns the new geometry object
  87740. */
  87741. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  87742. /**
  87743. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  87744. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  87745. * Be aware Math.random() could cause collisions, but:
  87746. * "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"
  87747. * @returns a string containing a new GUID
  87748. */
  87749. static RandomId(): string;
  87750. /** @hidden */
  87751. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  87752. private static _CleanMatricesWeights;
  87753. /**
  87754. * Create a new geometry from persisted data (Using .babylon file format)
  87755. * @param parsedVertexData defines the persisted data
  87756. * @param scene defines the hosting scene
  87757. * @param rootUrl defines the root url to use to load assets (like delayed data)
  87758. * @returns the new geometry object
  87759. */
  87760. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  87761. }
  87762. }
  87763. declare module BABYLON {
  87764. /**
  87765. * Define an interface for all classes that will get and set the data on vertices
  87766. */
  87767. export interface IGetSetVerticesData {
  87768. /**
  87769. * Gets a boolean indicating if specific vertex data is present
  87770. * @param kind defines the vertex data kind to use
  87771. * @returns true is data kind is present
  87772. */
  87773. isVerticesDataPresent(kind: string): boolean;
  87774. /**
  87775. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87776. * @param kind defines the data kind (Position, normal, etc...)
  87777. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87778. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87779. * @returns a float array containing vertex data
  87780. */
  87781. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87782. /**
  87783. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87784. * @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.
  87785. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87786. * @returns the indices array or an empty array if the mesh has no geometry
  87787. */
  87788. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87789. /**
  87790. * Set specific vertex data
  87791. * @param kind defines the data kind (Position, normal, etc...)
  87792. * @param data defines the vertex data to use
  87793. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87794. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87795. */
  87796. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  87797. /**
  87798. * Update a specific associated vertex buffer
  87799. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87800. * - VertexBuffer.PositionKind
  87801. * - VertexBuffer.UVKind
  87802. * - VertexBuffer.UV2Kind
  87803. * - VertexBuffer.UV3Kind
  87804. * - VertexBuffer.UV4Kind
  87805. * - VertexBuffer.UV5Kind
  87806. * - VertexBuffer.UV6Kind
  87807. * - VertexBuffer.ColorKind
  87808. * - VertexBuffer.MatricesIndicesKind
  87809. * - VertexBuffer.MatricesIndicesExtraKind
  87810. * - VertexBuffer.MatricesWeightsKind
  87811. * - VertexBuffer.MatricesWeightsExtraKind
  87812. * @param data defines the data source
  87813. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  87814. * @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)
  87815. */
  87816. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  87817. /**
  87818. * Creates a new index buffer
  87819. * @param indices defines the indices to store in the index buffer
  87820. * @param totalVertices defines the total number of vertices (could be null)
  87821. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87822. */
  87823. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  87824. }
  87825. /**
  87826. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  87827. */
  87828. export class VertexData {
  87829. /**
  87830. * Mesh side orientation : usually the external or front surface
  87831. */
  87832. static readonly FRONTSIDE: number;
  87833. /**
  87834. * Mesh side orientation : usually the internal or back surface
  87835. */
  87836. static readonly BACKSIDE: number;
  87837. /**
  87838. * Mesh side orientation : both internal and external or front and back surfaces
  87839. */
  87840. static readonly DOUBLESIDE: number;
  87841. /**
  87842. * Mesh side orientation : by default, `FRONTSIDE`
  87843. */
  87844. static readonly DEFAULTSIDE: number;
  87845. /**
  87846. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  87847. */
  87848. positions: Nullable<FloatArray>;
  87849. /**
  87850. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  87851. */
  87852. normals: Nullable<FloatArray>;
  87853. /**
  87854. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  87855. */
  87856. tangents: Nullable<FloatArray>;
  87857. /**
  87858. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87859. */
  87860. uvs: Nullable<FloatArray>;
  87861. /**
  87862. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87863. */
  87864. uvs2: Nullable<FloatArray>;
  87865. /**
  87866. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87867. */
  87868. uvs3: Nullable<FloatArray>;
  87869. /**
  87870. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87871. */
  87872. uvs4: Nullable<FloatArray>;
  87873. /**
  87874. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87875. */
  87876. uvs5: Nullable<FloatArray>;
  87877. /**
  87878. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87879. */
  87880. uvs6: Nullable<FloatArray>;
  87881. /**
  87882. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  87883. */
  87884. colors: Nullable<FloatArray>;
  87885. /**
  87886. * 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).
  87887. */
  87888. matricesIndices: Nullable<FloatArray>;
  87889. /**
  87890. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  87891. */
  87892. matricesWeights: Nullable<FloatArray>;
  87893. /**
  87894. * An array extending the number of possible indices
  87895. */
  87896. matricesIndicesExtra: Nullable<FloatArray>;
  87897. /**
  87898. * An array extending the number of possible weights when the number of indices is extended
  87899. */
  87900. matricesWeightsExtra: Nullable<FloatArray>;
  87901. /**
  87902. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  87903. */
  87904. indices: Nullable<IndicesArray>;
  87905. /**
  87906. * Uses the passed data array to set the set the values for the specified kind of data
  87907. * @param data a linear array of floating numbers
  87908. * @param kind the type of data that is being set, eg positions, colors etc
  87909. */
  87910. set(data: FloatArray, kind: string): void;
  87911. /**
  87912. * Associates the vertexData to the passed Mesh.
  87913. * Sets it as updatable or not (default `false`)
  87914. * @param mesh the mesh the vertexData is applied to
  87915. * @param updatable when used and having the value true allows new data to update the vertexData
  87916. * @returns the VertexData
  87917. */
  87918. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  87919. /**
  87920. * Associates the vertexData to the passed Geometry.
  87921. * Sets it as updatable or not (default `false`)
  87922. * @param geometry the geometry the vertexData is applied to
  87923. * @param updatable when used and having the value true allows new data to update the vertexData
  87924. * @returns VertexData
  87925. */
  87926. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  87927. /**
  87928. * Updates the associated mesh
  87929. * @param mesh the mesh to be updated
  87930. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87931. * @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
  87932. * @returns VertexData
  87933. */
  87934. updateMesh(mesh: Mesh): VertexData;
  87935. /**
  87936. * Updates the associated geometry
  87937. * @param geometry the geometry to be updated
  87938. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87939. * @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
  87940. * @returns VertexData.
  87941. */
  87942. updateGeometry(geometry: Geometry): VertexData;
  87943. private _applyTo;
  87944. private _update;
  87945. /**
  87946. * Transforms each position and each normal of the vertexData according to the passed Matrix
  87947. * @param matrix the transforming matrix
  87948. * @returns the VertexData
  87949. */
  87950. transform(matrix: Matrix): VertexData;
  87951. /**
  87952. * Merges the passed VertexData into the current one
  87953. * @param other the VertexData to be merged into the current one
  87954. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  87955. * @returns the modified VertexData
  87956. */
  87957. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  87958. private _mergeElement;
  87959. private _validate;
  87960. /**
  87961. * Serializes the VertexData
  87962. * @returns a serialized object
  87963. */
  87964. serialize(): any;
  87965. /**
  87966. * Extracts the vertexData from a mesh
  87967. * @param mesh the mesh from which to extract the VertexData
  87968. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  87969. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87970. * @returns the object VertexData associated to the passed mesh
  87971. */
  87972. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87973. /**
  87974. * Extracts the vertexData from the geometry
  87975. * @param geometry the geometry from which to extract the VertexData
  87976. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  87977. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87978. * @returns the object VertexData associated to the passed mesh
  87979. */
  87980. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87981. private static _ExtractFrom;
  87982. /**
  87983. * Creates the VertexData for a Ribbon
  87984. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  87985. * * pathArray array of paths, each of which an array of successive Vector3
  87986. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  87987. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  87988. * * 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
  87989. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87990. * * 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)
  87991. * * 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)
  87992. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  87993. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  87994. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  87995. * @returns the VertexData of the ribbon
  87996. */
  87997. static CreateRibbon(options: {
  87998. pathArray: Vector3[][];
  87999. closeArray?: boolean;
  88000. closePath?: boolean;
  88001. offset?: number;
  88002. sideOrientation?: number;
  88003. frontUVs?: Vector4;
  88004. backUVs?: Vector4;
  88005. invertUV?: boolean;
  88006. uvs?: Vector2[];
  88007. colors?: Color4[];
  88008. }): VertexData;
  88009. /**
  88010. * Creates the VertexData for a box
  88011. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88012. * * size sets the width, height and depth of the box to the value of size, optional default 1
  88013. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  88014. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  88015. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  88016. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88017. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88018. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88019. * * 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)
  88020. * * 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)
  88021. * @returns the VertexData of the box
  88022. */
  88023. static CreateBox(options: {
  88024. size?: number;
  88025. width?: number;
  88026. height?: number;
  88027. depth?: number;
  88028. faceUV?: Vector4[];
  88029. faceColors?: Color4[];
  88030. sideOrientation?: number;
  88031. frontUVs?: Vector4;
  88032. backUVs?: Vector4;
  88033. }): VertexData;
  88034. /**
  88035. * Creates the VertexData for a tiled box
  88036. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88037. * * faceTiles sets the pattern, tile size and number of tiles for a face
  88038. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88039. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88040. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88041. * @returns the VertexData of the box
  88042. */
  88043. static CreateTiledBox(options: {
  88044. pattern?: number;
  88045. width?: number;
  88046. height?: number;
  88047. depth?: number;
  88048. tileSize?: number;
  88049. tileWidth?: number;
  88050. tileHeight?: number;
  88051. alignHorizontal?: number;
  88052. alignVertical?: number;
  88053. faceUV?: Vector4[];
  88054. faceColors?: Color4[];
  88055. sideOrientation?: number;
  88056. }): VertexData;
  88057. /**
  88058. * Creates the VertexData for a tiled plane
  88059. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88060. * * pattern a limited pattern arrangement depending on the number
  88061. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  88062. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  88063. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  88064. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88065. * * 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)
  88066. * * 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)
  88067. * @returns the VertexData of the tiled plane
  88068. */
  88069. static CreateTiledPlane(options: {
  88070. pattern?: number;
  88071. tileSize?: number;
  88072. tileWidth?: number;
  88073. tileHeight?: number;
  88074. size?: number;
  88075. width?: number;
  88076. height?: number;
  88077. alignHorizontal?: number;
  88078. alignVertical?: number;
  88079. sideOrientation?: number;
  88080. frontUVs?: Vector4;
  88081. backUVs?: Vector4;
  88082. }): VertexData;
  88083. /**
  88084. * Creates the VertexData for an ellipsoid, defaults to a sphere
  88085. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88086. * * segments sets the number of horizontal strips optional, default 32
  88087. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  88088. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  88089. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  88090. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  88091. * * 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
  88092. * * 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
  88093. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88094. * * 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)
  88095. * * 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)
  88096. * @returns the VertexData of the ellipsoid
  88097. */
  88098. static CreateSphere(options: {
  88099. segments?: number;
  88100. diameter?: number;
  88101. diameterX?: number;
  88102. diameterY?: number;
  88103. diameterZ?: number;
  88104. arc?: number;
  88105. slice?: number;
  88106. sideOrientation?: number;
  88107. frontUVs?: Vector4;
  88108. backUVs?: Vector4;
  88109. }): VertexData;
  88110. /**
  88111. * Creates the VertexData for a cylinder, cone or prism
  88112. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88113. * * height sets the height (y direction) of the cylinder, optional, default 2
  88114. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  88115. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  88116. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  88117. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88118. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  88119. * * 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
  88120. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88121. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88122. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  88123. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  88124. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88125. * * 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)
  88126. * * 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)
  88127. * @returns the VertexData of the cylinder, cone or prism
  88128. */
  88129. static CreateCylinder(options: {
  88130. height?: number;
  88131. diameterTop?: number;
  88132. diameterBottom?: number;
  88133. diameter?: number;
  88134. tessellation?: number;
  88135. subdivisions?: number;
  88136. arc?: number;
  88137. faceColors?: Color4[];
  88138. faceUV?: Vector4[];
  88139. hasRings?: boolean;
  88140. enclose?: boolean;
  88141. sideOrientation?: number;
  88142. frontUVs?: Vector4;
  88143. backUVs?: Vector4;
  88144. }): VertexData;
  88145. /**
  88146. * Creates the VertexData for a torus
  88147. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88148. * * diameter the diameter of the torus, optional default 1
  88149. * * thickness the diameter of the tube forming the torus, optional default 0.5
  88150. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88151. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88152. * * 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)
  88153. * * 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)
  88154. * @returns the VertexData of the torus
  88155. */
  88156. static CreateTorus(options: {
  88157. diameter?: number;
  88158. thickness?: number;
  88159. tessellation?: number;
  88160. sideOrientation?: number;
  88161. frontUVs?: Vector4;
  88162. backUVs?: Vector4;
  88163. }): VertexData;
  88164. /**
  88165. * Creates the VertexData of the LineSystem
  88166. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  88167. * - lines an array of lines, each line being an array of successive Vector3
  88168. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  88169. * @returns the VertexData of the LineSystem
  88170. */
  88171. static CreateLineSystem(options: {
  88172. lines: Vector3[][];
  88173. colors?: Nullable<Color4[][]>;
  88174. }): VertexData;
  88175. /**
  88176. * Create the VertexData for a DashedLines
  88177. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  88178. * - points an array successive Vector3
  88179. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  88180. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  88181. * - dashNb the intended total number of dashes, optional, default 200
  88182. * @returns the VertexData for the DashedLines
  88183. */
  88184. static CreateDashedLines(options: {
  88185. points: Vector3[];
  88186. dashSize?: number;
  88187. gapSize?: number;
  88188. dashNb?: number;
  88189. }): VertexData;
  88190. /**
  88191. * Creates the VertexData for a Ground
  88192. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88193. * - width the width (x direction) of the ground, optional, default 1
  88194. * - height the height (z direction) of the ground, optional, default 1
  88195. * - subdivisions the number of subdivisions per side, optional, default 1
  88196. * @returns the VertexData of the Ground
  88197. */
  88198. static CreateGround(options: {
  88199. width?: number;
  88200. height?: number;
  88201. subdivisions?: number;
  88202. subdivisionsX?: number;
  88203. subdivisionsY?: number;
  88204. }): VertexData;
  88205. /**
  88206. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  88207. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88208. * * xmin the ground minimum X coordinate, optional, default -1
  88209. * * zmin the ground minimum Z coordinate, optional, default -1
  88210. * * xmax the ground maximum X coordinate, optional, default 1
  88211. * * zmax the ground maximum Z coordinate, optional, default 1
  88212. * * 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}
  88213. * * 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}
  88214. * @returns the VertexData of the TiledGround
  88215. */
  88216. static CreateTiledGround(options: {
  88217. xmin: number;
  88218. zmin: number;
  88219. xmax: number;
  88220. zmax: number;
  88221. subdivisions?: {
  88222. w: number;
  88223. h: number;
  88224. };
  88225. precision?: {
  88226. w: number;
  88227. h: number;
  88228. };
  88229. }): VertexData;
  88230. /**
  88231. * Creates the VertexData of the Ground designed from a heightmap
  88232. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  88233. * * width the width (x direction) of the ground
  88234. * * height the height (z direction) of the ground
  88235. * * subdivisions the number of subdivisions per side
  88236. * * minHeight the minimum altitude on the ground, optional, default 0
  88237. * * maxHeight the maximum altitude on the ground, optional default 1
  88238. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  88239. * * buffer the array holding the image color data
  88240. * * bufferWidth the width of image
  88241. * * bufferHeight the height of image
  88242. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  88243. * @returns the VertexData of the Ground designed from a heightmap
  88244. */
  88245. static CreateGroundFromHeightMap(options: {
  88246. width: number;
  88247. height: number;
  88248. subdivisions: number;
  88249. minHeight: number;
  88250. maxHeight: number;
  88251. colorFilter: Color3;
  88252. buffer: Uint8Array;
  88253. bufferWidth: number;
  88254. bufferHeight: number;
  88255. alphaFilter: number;
  88256. }): VertexData;
  88257. /**
  88258. * Creates the VertexData for a Plane
  88259. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  88260. * * size sets the width and height of the plane to the value of size, optional default 1
  88261. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  88262. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  88263. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88264. * * 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)
  88265. * * 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)
  88266. * @returns the VertexData of the box
  88267. */
  88268. static CreatePlane(options: {
  88269. size?: number;
  88270. width?: number;
  88271. height?: number;
  88272. sideOrientation?: number;
  88273. frontUVs?: Vector4;
  88274. backUVs?: Vector4;
  88275. }): VertexData;
  88276. /**
  88277. * Creates the VertexData of the Disc or regular Polygon
  88278. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  88279. * * radius the radius of the disc, optional default 0.5
  88280. * * tessellation the number of polygon sides, optional, default 64
  88281. * * 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
  88282. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88283. * * 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)
  88284. * * 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)
  88285. * @returns the VertexData of the box
  88286. */
  88287. static CreateDisc(options: {
  88288. radius?: number;
  88289. tessellation?: number;
  88290. arc?: number;
  88291. sideOrientation?: number;
  88292. frontUVs?: Vector4;
  88293. backUVs?: Vector4;
  88294. }): VertexData;
  88295. /**
  88296. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  88297. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  88298. * @param polygon a mesh built from polygonTriangulation.build()
  88299. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88300. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88301. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88302. * @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)
  88303. * @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)
  88304. * @returns the VertexData of the Polygon
  88305. */
  88306. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  88307. /**
  88308. * Creates the VertexData of the IcoSphere
  88309. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  88310. * * radius the radius of the IcoSphere, optional default 1
  88311. * * radiusX allows stretching in the x direction, optional, default radius
  88312. * * radiusY allows stretching in the y direction, optional, default radius
  88313. * * radiusZ allows stretching in the z direction, optional, default radius
  88314. * * flat when true creates a flat shaded mesh, optional, default true
  88315. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88316. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88317. * * 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)
  88318. * * 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)
  88319. * @returns the VertexData of the IcoSphere
  88320. */
  88321. static CreateIcoSphere(options: {
  88322. radius?: number;
  88323. radiusX?: number;
  88324. radiusY?: number;
  88325. radiusZ?: number;
  88326. flat?: boolean;
  88327. subdivisions?: number;
  88328. sideOrientation?: number;
  88329. frontUVs?: Vector4;
  88330. backUVs?: Vector4;
  88331. }): VertexData;
  88332. /**
  88333. * Creates the VertexData for a Polyhedron
  88334. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  88335. * * type provided types are:
  88336. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  88337. * * 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)
  88338. * * size the size of the IcoSphere, optional default 1
  88339. * * sizeX allows stretching in the x direction, optional, default size
  88340. * * sizeY allows stretching in the y direction, optional, default size
  88341. * * sizeZ allows stretching in the z direction, optional, default size
  88342. * * 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
  88343. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88344. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88345. * * flat when true creates a flat shaded mesh, optional, default true
  88346. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88347. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88348. * * 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)
  88349. * * 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)
  88350. * @returns the VertexData of the Polyhedron
  88351. */
  88352. static CreatePolyhedron(options: {
  88353. type?: number;
  88354. size?: number;
  88355. sizeX?: number;
  88356. sizeY?: number;
  88357. sizeZ?: number;
  88358. custom?: any;
  88359. faceUV?: Vector4[];
  88360. faceColors?: Color4[];
  88361. flat?: boolean;
  88362. sideOrientation?: number;
  88363. frontUVs?: Vector4;
  88364. backUVs?: Vector4;
  88365. }): VertexData;
  88366. /**
  88367. * Creates the VertexData for a TorusKnot
  88368. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  88369. * * radius the radius of the torus knot, optional, default 2
  88370. * * tube the thickness of the tube, optional, default 0.5
  88371. * * radialSegments the number of sides on each tube segments, optional, default 32
  88372. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  88373. * * p the number of windings around the z axis, optional, default 2
  88374. * * q the number of windings around the x axis, optional, default 3
  88375. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88376. * * 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)
  88377. * * 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)
  88378. * @returns the VertexData of the Torus Knot
  88379. */
  88380. static CreateTorusKnot(options: {
  88381. radius?: number;
  88382. tube?: number;
  88383. radialSegments?: number;
  88384. tubularSegments?: number;
  88385. p?: number;
  88386. q?: number;
  88387. sideOrientation?: number;
  88388. frontUVs?: Vector4;
  88389. backUVs?: Vector4;
  88390. }): VertexData;
  88391. /**
  88392. * Compute normals for given positions and indices
  88393. * @param positions an array of vertex positions, [...., x, y, z, ......]
  88394. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  88395. * @param normals an array of vertex normals, [...., x, y, z, ......]
  88396. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  88397. * * facetNormals : optional array of facet normals (vector3)
  88398. * * facetPositions : optional array of facet positions (vector3)
  88399. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  88400. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  88401. * * bInfo : optional bounding info, required for facetPartitioning computation
  88402. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  88403. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  88404. * * useRightHandedSystem: optional boolean to for right handed system computation
  88405. * * depthSort : optional boolean to enable the facet depth sort computation
  88406. * * distanceTo : optional Vector3 to compute the facet depth from this location
  88407. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  88408. */
  88409. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  88410. facetNormals?: any;
  88411. facetPositions?: any;
  88412. facetPartitioning?: any;
  88413. ratio?: number;
  88414. bInfo?: any;
  88415. bbSize?: Vector3;
  88416. subDiv?: any;
  88417. useRightHandedSystem?: boolean;
  88418. depthSort?: boolean;
  88419. distanceTo?: Vector3;
  88420. depthSortedFacets?: any;
  88421. }): void;
  88422. /** @hidden */
  88423. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  88424. /**
  88425. * Applies VertexData created from the imported parameters to the geometry
  88426. * @param parsedVertexData the parsed data from an imported file
  88427. * @param geometry the geometry to apply the VertexData to
  88428. */
  88429. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  88430. }
  88431. }
  88432. declare module BABYLON {
  88433. /**
  88434. * Defines a target to use with MorphTargetManager
  88435. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88436. */
  88437. export class MorphTarget implements IAnimatable {
  88438. /** defines the name of the target */
  88439. name: string;
  88440. /**
  88441. * Gets or sets the list of animations
  88442. */
  88443. animations: Animation[];
  88444. private _scene;
  88445. private _positions;
  88446. private _normals;
  88447. private _tangents;
  88448. private _uvs;
  88449. private _influence;
  88450. /**
  88451. * Observable raised when the influence changes
  88452. */
  88453. onInfluenceChanged: Observable<boolean>;
  88454. /** @hidden */
  88455. _onDataLayoutChanged: Observable<void>;
  88456. /**
  88457. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  88458. */
  88459. influence: number;
  88460. /**
  88461. * Gets or sets the id of the morph Target
  88462. */
  88463. id: string;
  88464. private _animationPropertiesOverride;
  88465. /**
  88466. * Gets or sets the animation properties override
  88467. */
  88468. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88469. /**
  88470. * Creates a new MorphTarget
  88471. * @param name defines the name of the target
  88472. * @param influence defines the influence to use
  88473. * @param scene defines the scene the morphtarget belongs to
  88474. */
  88475. constructor(
  88476. /** defines the name of the target */
  88477. name: string, influence?: number, scene?: Nullable<Scene>);
  88478. /**
  88479. * Gets a boolean defining if the target contains position data
  88480. */
  88481. readonly hasPositions: boolean;
  88482. /**
  88483. * Gets a boolean defining if the target contains normal data
  88484. */
  88485. readonly hasNormals: boolean;
  88486. /**
  88487. * Gets a boolean defining if the target contains tangent data
  88488. */
  88489. readonly hasTangents: boolean;
  88490. /**
  88491. * Gets a boolean defining if the target contains texture coordinates data
  88492. */
  88493. readonly hasUVs: boolean;
  88494. /**
  88495. * Affects position data to this target
  88496. * @param data defines the position data to use
  88497. */
  88498. setPositions(data: Nullable<FloatArray>): void;
  88499. /**
  88500. * Gets the position data stored in this target
  88501. * @returns a FloatArray containing the position data (or null if not present)
  88502. */
  88503. getPositions(): Nullable<FloatArray>;
  88504. /**
  88505. * Affects normal data to this target
  88506. * @param data defines the normal data to use
  88507. */
  88508. setNormals(data: Nullable<FloatArray>): void;
  88509. /**
  88510. * Gets the normal data stored in this target
  88511. * @returns a FloatArray containing the normal data (or null if not present)
  88512. */
  88513. getNormals(): Nullable<FloatArray>;
  88514. /**
  88515. * Affects tangent data to this target
  88516. * @param data defines the tangent data to use
  88517. */
  88518. setTangents(data: Nullable<FloatArray>): void;
  88519. /**
  88520. * Gets the tangent data stored in this target
  88521. * @returns a FloatArray containing the tangent data (or null if not present)
  88522. */
  88523. getTangents(): Nullable<FloatArray>;
  88524. /**
  88525. * Affects texture coordinates data to this target
  88526. * @param data defines the texture coordinates data to use
  88527. */
  88528. setUVs(data: Nullable<FloatArray>): void;
  88529. /**
  88530. * Gets the texture coordinates data stored in this target
  88531. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  88532. */
  88533. getUVs(): Nullable<FloatArray>;
  88534. /**
  88535. * Serializes the current target into a Serialization object
  88536. * @returns the serialized object
  88537. */
  88538. serialize(): any;
  88539. /**
  88540. * Returns the string "MorphTarget"
  88541. * @returns "MorphTarget"
  88542. */
  88543. getClassName(): string;
  88544. /**
  88545. * Creates a new target from serialized data
  88546. * @param serializationObject defines the serialized data to use
  88547. * @returns a new MorphTarget
  88548. */
  88549. static Parse(serializationObject: any): MorphTarget;
  88550. /**
  88551. * Creates a MorphTarget from mesh data
  88552. * @param mesh defines the source mesh
  88553. * @param name defines the name to use for the new target
  88554. * @param influence defines the influence to attach to the target
  88555. * @returns a new MorphTarget
  88556. */
  88557. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  88558. }
  88559. }
  88560. declare module BABYLON {
  88561. /**
  88562. * This class is used to deform meshes using morphing between different targets
  88563. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88564. */
  88565. export class MorphTargetManager {
  88566. private _targets;
  88567. private _targetInfluenceChangedObservers;
  88568. private _targetDataLayoutChangedObservers;
  88569. private _activeTargets;
  88570. private _scene;
  88571. private _influences;
  88572. private _supportsNormals;
  88573. private _supportsTangents;
  88574. private _supportsUVs;
  88575. private _vertexCount;
  88576. private _uniqueId;
  88577. private _tempInfluences;
  88578. /**
  88579. * Gets or sets a boolean indicating if normals must be morphed
  88580. */
  88581. enableNormalMorphing: boolean;
  88582. /**
  88583. * Gets or sets a boolean indicating if tangents must be morphed
  88584. */
  88585. enableTangentMorphing: boolean;
  88586. /**
  88587. * Gets or sets a boolean indicating if UV must be morphed
  88588. */
  88589. enableUVMorphing: boolean;
  88590. /**
  88591. * Creates a new MorphTargetManager
  88592. * @param scene defines the current scene
  88593. */
  88594. constructor(scene?: Nullable<Scene>);
  88595. /**
  88596. * Gets the unique ID of this manager
  88597. */
  88598. readonly uniqueId: number;
  88599. /**
  88600. * Gets the number of vertices handled by this manager
  88601. */
  88602. readonly vertexCount: number;
  88603. /**
  88604. * Gets a boolean indicating if this manager supports morphing of normals
  88605. */
  88606. readonly supportsNormals: boolean;
  88607. /**
  88608. * Gets a boolean indicating if this manager supports morphing of tangents
  88609. */
  88610. readonly supportsTangents: boolean;
  88611. /**
  88612. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  88613. */
  88614. readonly supportsUVs: boolean;
  88615. /**
  88616. * Gets the number of targets stored in this manager
  88617. */
  88618. readonly numTargets: number;
  88619. /**
  88620. * Gets the number of influencers (ie. the number of targets with influences > 0)
  88621. */
  88622. readonly numInfluencers: number;
  88623. /**
  88624. * Gets the list of influences (one per target)
  88625. */
  88626. readonly influences: Float32Array;
  88627. /**
  88628. * Gets the active target at specified index. An active target is a target with an influence > 0
  88629. * @param index defines the index to check
  88630. * @returns the requested target
  88631. */
  88632. getActiveTarget(index: number): MorphTarget;
  88633. /**
  88634. * Gets the target at specified index
  88635. * @param index defines the index to check
  88636. * @returns the requested target
  88637. */
  88638. getTarget(index: number): MorphTarget;
  88639. /**
  88640. * Add a new target to this manager
  88641. * @param target defines the target to add
  88642. */
  88643. addTarget(target: MorphTarget): void;
  88644. /**
  88645. * Removes a target from the manager
  88646. * @param target defines the target to remove
  88647. */
  88648. removeTarget(target: MorphTarget): void;
  88649. /**
  88650. * Serializes the current manager into a Serialization object
  88651. * @returns the serialized object
  88652. */
  88653. serialize(): any;
  88654. private _syncActiveTargets;
  88655. /**
  88656. * Syncrhonize the targets with all the meshes using this morph target manager
  88657. */
  88658. synchronize(): void;
  88659. /**
  88660. * Creates a new MorphTargetManager from serialized data
  88661. * @param serializationObject defines the serialized data
  88662. * @param scene defines the hosting scene
  88663. * @returns the new MorphTargetManager
  88664. */
  88665. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  88666. }
  88667. }
  88668. declare module BABYLON {
  88669. /**
  88670. * Class used to represent a specific level of detail of a mesh
  88671. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  88672. */
  88673. export class MeshLODLevel {
  88674. /** Defines the distance where this level should start being displayed */
  88675. distance: number;
  88676. /** Defines the mesh to use to render this level */
  88677. mesh: Nullable<Mesh>;
  88678. /**
  88679. * Creates a new LOD level
  88680. * @param distance defines the distance where this level should star being displayed
  88681. * @param mesh defines the mesh to use to render this level
  88682. */
  88683. constructor(
  88684. /** Defines the distance where this level should start being displayed */
  88685. distance: number,
  88686. /** Defines the mesh to use to render this level */
  88687. mesh: Nullable<Mesh>);
  88688. }
  88689. }
  88690. declare module BABYLON {
  88691. /**
  88692. * Mesh representing the gorund
  88693. */
  88694. export class GroundMesh extends Mesh {
  88695. /** If octree should be generated */
  88696. generateOctree: boolean;
  88697. private _heightQuads;
  88698. /** @hidden */
  88699. _subdivisionsX: number;
  88700. /** @hidden */
  88701. _subdivisionsY: number;
  88702. /** @hidden */
  88703. _width: number;
  88704. /** @hidden */
  88705. _height: number;
  88706. /** @hidden */
  88707. _minX: number;
  88708. /** @hidden */
  88709. _maxX: number;
  88710. /** @hidden */
  88711. _minZ: number;
  88712. /** @hidden */
  88713. _maxZ: number;
  88714. constructor(name: string, scene: Scene);
  88715. /**
  88716. * "GroundMesh"
  88717. * @returns "GroundMesh"
  88718. */
  88719. getClassName(): string;
  88720. /**
  88721. * The minimum of x and y subdivisions
  88722. */
  88723. readonly subdivisions: number;
  88724. /**
  88725. * X subdivisions
  88726. */
  88727. readonly subdivisionsX: number;
  88728. /**
  88729. * Y subdivisions
  88730. */
  88731. readonly subdivisionsY: number;
  88732. /**
  88733. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  88734. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  88735. * @param chunksCount the number of subdivisions for x and y
  88736. * @param octreeBlocksSize (Default: 32)
  88737. */
  88738. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  88739. /**
  88740. * Returns a height (y) value in the Worl system :
  88741. * the ground altitude at the coordinates (x, z) expressed in the World system.
  88742. * @param x x coordinate
  88743. * @param z z coordinate
  88744. * @returns the ground y position if (x, z) are outside the ground surface.
  88745. */
  88746. getHeightAtCoordinates(x: number, z: number): number;
  88747. /**
  88748. * Returns a normalized vector (Vector3) orthogonal to the ground
  88749. * at the ground coordinates (x, z) expressed in the World system.
  88750. * @param x x coordinate
  88751. * @param z z coordinate
  88752. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  88753. */
  88754. getNormalAtCoordinates(x: number, z: number): Vector3;
  88755. /**
  88756. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  88757. * at the ground coordinates (x, z) expressed in the World system.
  88758. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  88759. * @param x x coordinate
  88760. * @param z z coordinate
  88761. * @param ref vector to store the result
  88762. * @returns the GroundMesh.
  88763. */
  88764. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  88765. /**
  88766. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  88767. * if the ground has been updated.
  88768. * This can be used in the render loop.
  88769. * @returns the GroundMesh.
  88770. */
  88771. updateCoordinateHeights(): GroundMesh;
  88772. private _getFacetAt;
  88773. private _initHeightQuads;
  88774. private _computeHeightQuads;
  88775. /**
  88776. * Serializes this ground mesh
  88777. * @param serializationObject object to write serialization to
  88778. */
  88779. serialize(serializationObject: any): void;
  88780. /**
  88781. * Parses a serialized ground mesh
  88782. * @param parsedMesh the serialized mesh
  88783. * @param scene the scene to create the ground mesh in
  88784. * @returns the created ground mesh
  88785. */
  88786. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  88787. }
  88788. }
  88789. declare module BABYLON {
  88790. /**
  88791. * Interface for Physics-Joint data
  88792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88793. */
  88794. export interface PhysicsJointData {
  88795. /**
  88796. * The main pivot of the joint
  88797. */
  88798. mainPivot?: Vector3;
  88799. /**
  88800. * The connected pivot of the joint
  88801. */
  88802. connectedPivot?: Vector3;
  88803. /**
  88804. * The main axis of the joint
  88805. */
  88806. mainAxis?: Vector3;
  88807. /**
  88808. * The connected axis of the joint
  88809. */
  88810. connectedAxis?: Vector3;
  88811. /**
  88812. * The collision of the joint
  88813. */
  88814. collision?: boolean;
  88815. /**
  88816. * Native Oimo/Cannon/Energy data
  88817. */
  88818. nativeParams?: any;
  88819. }
  88820. /**
  88821. * This is a holder class for the physics joint created by the physics plugin
  88822. * It holds a set of functions to control the underlying joint
  88823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88824. */
  88825. export class PhysicsJoint {
  88826. /**
  88827. * The type of the physics joint
  88828. */
  88829. type: number;
  88830. /**
  88831. * The data for the physics joint
  88832. */
  88833. jointData: PhysicsJointData;
  88834. private _physicsJoint;
  88835. protected _physicsPlugin: IPhysicsEnginePlugin;
  88836. /**
  88837. * Initializes the physics joint
  88838. * @param type The type of the physics joint
  88839. * @param jointData The data for the physics joint
  88840. */
  88841. constructor(
  88842. /**
  88843. * The type of the physics joint
  88844. */
  88845. type: number,
  88846. /**
  88847. * The data for the physics joint
  88848. */
  88849. jointData: PhysicsJointData);
  88850. /**
  88851. * Gets the physics joint
  88852. */
  88853. /**
  88854. * Sets the physics joint
  88855. */
  88856. physicsJoint: any;
  88857. /**
  88858. * Sets the physics plugin
  88859. */
  88860. physicsPlugin: IPhysicsEnginePlugin;
  88861. /**
  88862. * Execute a function that is physics-plugin specific.
  88863. * @param {Function} func the function that will be executed.
  88864. * It accepts two parameters: the physics world and the physics joint
  88865. */
  88866. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  88867. /**
  88868. * Distance-Joint type
  88869. */
  88870. static DistanceJoint: number;
  88871. /**
  88872. * Hinge-Joint type
  88873. */
  88874. static HingeJoint: number;
  88875. /**
  88876. * Ball-and-Socket joint type
  88877. */
  88878. static BallAndSocketJoint: number;
  88879. /**
  88880. * Wheel-Joint type
  88881. */
  88882. static WheelJoint: number;
  88883. /**
  88884. * Slider-Joint type
  88885. */
  88886. static SliderJoint: number;
  88887. /**
  88888. * Prismatic-Joint type
  88889. */
  88890. static PrismaticJoint: number;
  88891. /**
  88892. * Universal-Joint type
  88893. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  88894. */
  88895. static UniversalJoint: number;
  88896. /**
  88897. * Hinge-Joint 2 type
  88898. */
  88899. static Hinge2Joint: number;
  88900. /**
  88901. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  88902. */
  88903. static PointToPointJoint: number;
  88904. /**
  88905. * Spring-Joint type
  88906. */
  88907. static SpringJoint: number;
  88908. /**
  88909. * Lock-Joint type
  88910. */
  88911. static LockJoint: number;
  88912. }
  88913. /**
  88914. * A class representing a physics distance joint
  88915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88916. */
  88917. export class DistanceJoint extends PhysicsJoint {
  88918. /**
  88919. *
  88920. * @param jointData The data for the Distance-Joint
  88921. */
  88922. constructor(jointData: DistanceJointData);
  88923. /**
  88924. * Update the predefined distance.
  88925. * @param maxDistance The maximum preferred distance
  88926. * @param minDistance The minimum preferred distance
  88927. */
  88928. updateDistance(maxDistance: number, minDistance?: number): void;
  88929. }
  88930. /**
  88931. * Represents a Motor-Enabled Joint
  88932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88933. */
  88934. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  88935. /**
  88936. * Initializes the Motor-Enabled Joint
  88937. * @param type The type of the joint
  88938. * @param jointData The physica joint data for the joint
  88939. */
  88940. constructor(type: number, jointData: PhysicsJointData);
  88941. /**
  88942. * Set the motor values.
  88943. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88944. * @param force the force to apply
  88945. * @param maxForce max force for this motor.
  88946. */
  88947. setMotor(force?: number, maxForce?: number): void;
  88948. /**
  88949. * Set the motor's limits.
  88950. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88951. * @param upperLimit The upper limit of the motor
  88952. * @param lowerLimit The lower limit of the motor
  88953. */
  88954. setLimit(upperLimit: number, lowerLimit?: number): void;
  88955. }
  88956. /**
  88957. * This class represents a single physics Hinge-Joint
  88958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88959. */
  88960. export class HingeJoint extends MotorEnabledJoint {
  88961. /**
  88962. * Initializes the Hinge-Joint
  88963. * @param jointData The joint data for the Hinge-Joint
  88964. */
  88965. constructor(jointData: PhysicsJointData);
  88966. /**
  88967. * Set the motor values.
  88968. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88969. * @param {number} force the force to apply
  88970. * @param {number} maxForce max force for this motor.
  88971. */
  88972. setMotor(force?: number, maxForce?: number): void;
  88973. /**
  88974. * Set the motor's limits.
  88975. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88976. * @param upperLimit The upper limit of the motor
  88977. * @param lowerLimit The lower limit of the motor
  88978. */
  88979. setLimit(upperLimit: number, lowerLimit?: number): void;
  88980. }
  88981. /**
  88982. * This class represents a dual hinge physics joint (same as wheel joint)
  88983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88984. */
  88985. export class Hinge2Joint extends MotorEnabledJoint {
  88986. /**
  88987. * Initializes the Hinge2-Joint
  88988. * @param jointData The joint data for the Hinge2-Joint
  88989. */
  88990. constructor(jointData: PhysicsJointData);
  88991. /**
  88992. * Set the motor values.
  88993. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88994. * @param {number} targetSpeed the speed the motor is to reach
  88995. * @param {number} maxForce max force for this motor.
  88996. * @param {motorIndex} the motor's index, 0 or 1.
  88997. */
  88998. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  88999. /**
  89000. * Set the motor limits.
  89001. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89002. * @param {number} upperLimit the upper limit
  89003. * @param {number} lowerLimit lower limit
  89004. * @param {motorIndex} the motor's index, 0 or 1.
  89005. */
  89006. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89007. }
  89008. /**
  89009. * Interface for a motor enabled joint
  89010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89011. */
  89012. export interface IMotorEnabledJoint {
  89013. /**
  89014. * Physics joint
  89015. */
  89016. physicsJoint: any;
  89017. /**
  89018. * Sets the motor of the motor-enabled joint
  89019. * @param force The force of the motor
  89020. * @param maxForce The maximum force of the motor
  89021. * @param motorIndex The index of the motor
  89022. */
  89023. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  89024. /**
  89025. * Sets the limit of the motor
  89026. * @param upperLimit The upper limit of the motor
  89027. * @param lowerLimit The lower limit of the motor
  89028. * @param motorIndex The index of the motor
  89029. */
  89030. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89031. }
  89032. /**
  89033. * Joint data for a Distance-Joint
  89034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89035. */
  89036. export interface DistanceJointData extends PhysicsJointData {
  89037. /**
  89038. * Max distance the 2 joint objects can be apart
  89039. */
  89040. maxDistance: number;
  89041. }
  89042. /**
  89043. * Joint data from a spring joint
  89044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89045. */
  89046. export interface SpringJointData extends PhysicsJointData {
  89047. /**
  89048. * Length of the spring
  89049. */
  89050. length: number;
  89051. /**
  89052. * Stiffness of the spring
  89053. */
  89054. stiffness: number;
  89055. /**
  89056. * Damping of the spring
  89057. */
  89058. damping: number;
  89059. /** this callback will be called when applying the force to the impostors. */
  89060. forceApplicationCallback: () => void;
  89061. }
  89062. }
  89063. declare module BABYLON {
  89064. /**
  89065. * Holds the data for the raycast result
  89066. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89067. */
  89068. export class PhysicsRaycastResult {
  89069. private _hasHit;
  89070. private _hitDistance;
  89071. private _hitNormalWorld;
  89072. private _hitPointWorld;
  89073. private _rayFromWorld;
  89074. private _rayToWorld;
  89075. /**
  89076. * Gets if there was a hit
  89077. */
  89078. readonly hasHit: boolean;
  89079. /**
  89080. * Gets the distance from the hit
  89081. */
  89082. readonly hitDistance: number;
  89083. /**
  89084. * Gets the hit normal/direction in the world
  89085. */
  89086. readonly hitNormalWorld: Vector3;
  89087. /**
  89088. * Gets the hit point in the world
  89089. */
  89090. readonly hitPointWorld: Vector3;
  89091. /**
  89092. * Gets the ray "start point" of the ray in the world
  89093. */
  89094. readonly rayFromWorld: Vector3;
  89095. /**
  89096. * Gets the ray "end point" of the ray in the world
  89097. */
  89098. readonly rayToWorld: Vector3;
  89099. /**
  89100. * Sets the hit data (normal & point in world space)
  89101. * @param hitNormalWorld defines the normal in world space
  89102. * @param hitPointWorld defines the point in world space
  89103. */
  89104. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  89105. /**
  89106. * Sets the distance from the start point to the hit point
  89107. * @param distance
  89108. */
  89109. setHitDistance(distance: number): void;
  89110. /**
  89111. * Calculates the distance manually
  89112. */
  89113. calculateHitDistance(): void;
  89114. /**
  89115. * Resets all the values to default
  89116. * @param from The from point on world space
  89117. * @param to The to point on world space
  89118. */
  89119. reset(from?: Vector3, to?: Vector3): void;
  89120. }
  89121. /**
  89122. * Interface for the size containing width and height
  89123. */
  89124. interface IXYZ {
  89125. /**
  89126. * X
  89127. */
  89128. x: number;
  89129. /**
  89130. * Y
  89131. */
  89132. y: number;
  89133. /**
  89134. * Z
  89135. */
  89136. z: number;
  89137. }
  89138. }
  89139. declare module BABYLON {
  89140. /**
  89141. * Interface used to describe a physics joint
  89142. */
  89143. export interface PhysicsImpostorJoint {
  89144. /** Defines the main impostor to which the joint is linked */
  89145. mainImpostor: PhysicsImpostor;
  89146. /** Defines the impostor that is connected to the main impostor using this joint */
  89147. connectedImpostor: PhysicsImpostor;
  89148. /** Defines the joint itself */
  89149. joint: PhysicsJoint;
  89150. }
  89151. /** @hidden */
  89152. export interface IPhysicsEnginePlugin {
  89153. world: any;
  89154. name: string;
  89155. setGravity(gravity: Vector3): void;
  89156. setTimeStep(timeStep: number): void;
  89157. getTimeStep(): number;
  89158. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  89159. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89160. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89161. generatePhysicsBody(impostor: PhysicsImpostor): void;
  89162. removePhysicsBody(impostor: PhysicsImpostor): void;
  89163. generateJoint(joint: PhysicsImpostorJoint): void;
  89164. removeJoint(joint: PhysicsImpostorJoint): void;
  89165. isSupported(): boolean;
  89166. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  89167. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  89168. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89169. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89170. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89171. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89172. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  89173. getBodyMass(impostor: PhysicsImpostor): number;
  89174. getBodyFriction(impostor: PhysicsImpostor): number;
  89175. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  89176. getBodyRestitution(impostor: PhysicsImpostor): number;
  89177. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  89178. getBodyPressure?(impostor: PhysicsImpostor): number;
  89179. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  89180. getBodyStiffness?(impostor: PhysicsImpostor): number;
  89181. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  89182. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  89183. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  89184. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  89185. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  89186. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89187. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89188. sleepBody(impostor: PhysicsImpostor): void;
  89189. wakeUpBody(impostor: PhysicsImpostor): void;
  89190. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89191. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  89192. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  89193. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89194. getRadius(impostor: PhysicsImpostor): number;
  89195. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  89196. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  89197. dispose(): void;
  89198. }
  89199. /**
  89200. * Interface used to define a physics engine
  89201. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  89202. */
  89203. export interface IPhysicsEngine {
  89204. /**
  89205. * Gets the gravity vector used by the simulation
  89206. */
  89207. gravity: Vector3;
  89208. /**
  89209. * Sets the gravity vector used by the simulation
  89210. * @param gravity defines the gravity vector to use
  89211. */
  89212. setGravity(gravity: Vector3): void;
  89213. /**
  89214. * Set the time step of the physics engine.
  89215. * Default is 1/60.
  89216. * To slow it down, enter 1/600 for example.
  89217. * To speed it up, 1/30
  89218. * @param newTimeStep the new timestep to apply to this world.
  89219. */
  89220. setTimeStep(newTimeStep: number): void;
  89221. /**
  89222. * Get the time step of the physics engine.
  89223. * @returns the current time step
  89224. */
  89225. getTimeStep(): number;
  89226. /**
  89227. * Release all resources
  89228. */
  89229. dispose(): void;
  89230. /**
  89231. * Gets the name of the current physics plugin
  89232. * @returns the name of the plugin
  89233. */
  89234. getPhysicsPluginName(): string;
  89235. /**
  89236. * Adding a new impostor for the impostor tracking.
  89237. * This will be done by the impostor itself.
  89238. * @param impostor the impostor to add
  89239. */
  89240. addImpostor(impostor: PhysicsImpostor): void;
  89241. /**
  89242. * Remove an impostor from the engine.
  89243. * This impostor and its mesh will not longer be updated by the physics engine.
  89244. * @param impostor the impostor to remove
  89245. */
  89246. removeImpostor(impostor: PhysicsImpostor): void;
  89247. /**
  89248. * Add a joint to the physics engine
  89249. * @param mainImpostor defines the main impostor to which the joint is added.
  89250. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  89251. * @param joint defines the joint that will connect both impostors.
  89252. */
  89253. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89254. /**
  89255. * Removes a joint from the simulation
  89256. * @param mainImpostor defines the impostor used with the joint
  89257. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  89258. * @param joint defines the joint to remove
  89259. */
  89260. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89261. /**
  89262. * Gets the current plugin used to run the simulation
  89263. * @returns current plugin
  89264. */
  89265. getPhysicsPlugin(): IPhysicsEnginePlugin;
  89266. /**
  89267. * Gets the list of physic impostors
  89268. * @returns an array of PhysicsImpostor
  89269. */
  89270. getImpostors(): Array<PhysicsImpostor>;
  89271. /**
  89272. * Gets the impostor for a physics enabled object
  89273. * @param object defines the object impersonated by the impostor
  89274. * @returns the PhysicsImpostor or null if not found
  89275. */
  89276. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89277. /**
  89278. * Gets the impostor for a physics body object
  89279. * @param body defines physics body used by the impostor
  89280. * @returns the PhysicsImpostor or null if not found
  89281. */
  89282. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  89283. /**
  89284. * Does a raycast in the physics world
  89285. * @param from when should the ray start?
  89286. * @param to when should the ray end?
  89287. * @returns PhysicsRaycastResult
  89288. */
  89289. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89290. /**
  89291. * Called by the scene. No need to call it.
  89292. * @param delta defines the timespam between frames
  89293. */
  89294. _step(delta: number): void;
  89295. }
  89296. }
  89297. declare module BABYLON {
  89298. /**
  89299. * The interface for the physics imposter parameters
  89300. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89301. */
  89302. export interface PhysicsImpostorParameters {
  89303. /**
  89304. * The mass of the physics imposter
  89305. */
  89306. mass: number;
  89307. /**
  89308. * The friction of the physics imposter
  89309. */
  89310. friction?: number;
  89311. /**
  89312. * The coefficient of restitution of the physics imposter
  89313. */
  89314. restitution?: number;
  89315. /**
  89316. * The native options of the physics imposter
  89317. */
  89318. nativeOptions?: any;
  89319. /**
  89320. * Specifies if the parent should be ignored
  89321. */
  89322. ignoreParent?: boolean;
  89323. /**
  89324. * Specifies if bi-directional transformations should be disabled
  89325. */
  89326. disableBidirectionalTransformation?: boolean;
  89327. /**
  89328. * The pressure inside the physics imposter, soft object only
  89329. */
  89330. pressure?: number;
  89331. /**
  89332. * The stiffness the physics imposter, soft object only
  89333. */
  89334. stiffness?: number;
  89335. /**
  89336. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  89337. */
  89338. velocityIterations?: number;
  89339. /**
  89340. * The number of iterations used in maintaining consistent vertex positions, soft object only
  89341. */
  89342. positionIterations?: number;
  89343. /**
  89344. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  89345. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  89346. * Add to fix multiple points
  89347. */
  89348. fixedPoints?: number;
  89349. /**
  89350. * The collision margin around a soft object
  89351. */
  89352. margin?: number;
  89353. /**
  89354. * The collision margin around a soft object
  89355. */
  89356. damping?: number;
  89357. /**
  89358. * The path for a rope based on an extrusion
  89359. */
  89360. path?: any;
  89361. /**
  89362. * The shape of an extrusion used for a rope based on an extrusion
  89363. */
  89364. shape?: any;
  89365. }
  89366. /**
  89367. * Interface for a physics-enabled object
  89368. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89369. */
  89370. export interface IPhysicsEnabledObject {
  89371. /**
  89372. * The position of the physics-enabled object
  89373. */
  89374. position: Vector3;
  89375. /**
  89376. * The rotation of the physics-enabled object
  89377. */
  89378. rotationQuaternion: Nullable<Quaternion>;
  89379. /**
  89380. * The scale of the physics-enabled object
  89381. */
  89382. scaling: Vector3;
  89383. /**
  89384. * The rotation of the physics-enabled object
  89385. */
  89386. rotation?: Vector3;
  89387. /**
  89388. * The parent of the physics-enabled object
  89389. */
  89390. parent?: any;
  89391. /**
  89392. * The bounding info of the physics-enabled object
  89393. * @returns The bounding info of the physics-enabled object
  89394. */
  89395. getBoundingInfo(): BoundingInfo;
  89396. /**
  89397. * Computes the world matrix
  89398. * @param force Specifies if the world matrix should be computed by force
  89399. * @returns A world matrix
  89400. */
  89401. computeWorldMatrix(force: boolean): Matrix;
  89402. /**
  89403. * Gets the world matrix
  89404. * @returns A world matrix
  89405. */
  89406. getWorldMatrix?(): Matrix;
  89407. /**
  89408. * Gets the child meshes
  89409. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  89410. * @returns An array of abstract meshes
  89411. */
  89412. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  89413. /**
  89414. * Gets the vertex data
  89415. * @param kind The type of vertex data
  89416. * @returns A nullable array of numbers, or a float32 array
  89417. */
  89418. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  89419. /**
  89420. * Gets the indices from the mesh
  89421. * @returns A nullable array of index arrays
  89422. */
  89423. getIndices?(): Nullable<IndicesArray>;
  89424. /**
  89425. * Gets the scene from the mesh
  89426. * @returns the indices array or null
  89427. */
  89428. getScene?(): Scene;
  89429. /**
  89430. * Gets the absolute position from the mesh
  89431. * @returns the absolute position
  89432. */
  89433. getAbsolutePosition(): Vector3;
  89434. /**
  89435. * Gets the absolute pivot point from the mesh
  89436. * @returns the absolute pivot point
  89437. */
  89438. getAbsolutePivotPoint(): Vector3;
  89439. /**
  89440. * Rotates the mesh
  89441. * @param axis The axis of rotation
  89442. * @param amount The amount of rotation
  89443. * @param space The space of the rotation
  89444. * @returns The rotation transform node
  89445. */
  89446. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  89447. /**
  89448. * Translates the mesh
  89449. * @param axis The axis of translation
  89450. * @param distance The distance of translation
  89451. * @param space The space of the translation
  89452. * @returns The transform node
  89453. */
  89454. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  89455. /**
  89456. * Sets the absolute position of the mesh
  89457. * @param absolutePosition The absolute position of the mesh
  89458. * @returns The transform node
  89459. */
  89460. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  89461. /**
  89462. * Gets the class name of the mesh
  89463. * @returns The class name
  89464. */
  89465. getClassName(): string;
  89466. }
  89467. /**
  89468. * Represents a physics imposter
  89469. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89470. */
  89471. export class PhysicsImpostor {
  89472. /**
  89473. * The physics-enabled object used as the physics imposter
  89474. */
  89475. object: IPhysicsEnabledObject;
  89476. /**
  89477. * The type of the physics imposter
  89478. */
  89479. type: number;
  89480. private _options;
  89481. private _scene?;
  89482. /**
  89483. * The default object size of the imposter
  89484. */
  89485. static DEFAULT_OBJECT_SIZE: Vector3;
  89486. /**
  89487. * The identity quaternion of the imposter
  89488. */
  89489. static IDENTITY_QUATERNION: Quaternion;
  89490. /** @hidden */
  89491. _pluginData: any;
  89492. private _physicsEngine;
  89493. private _physicsBody;
  89494. private _bodyUpdateRequired;
  89495. private _onBeforePhysicsStepCallbacks;
  89496. private _onAfterPhysicsStepCallbacks;
  89497. /** @hidden */
  89498. _onPhysicsCollideCallbacks: Array<{
  89499. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  89500. otherImpostors: Array<PhysicsImpostor>;
  89501. }>;
  89502. private _deltaPosition;
  89503. private _deltaRotation;
  89504. private _deltaRotationConjugated;
  89505. /** @hidden */
  89506. _isFromLine: boolean;
  89507. private _parent;
  89508. private _isDisposed;
  89509. private static _tmpVecs;
  89510. private static _tmpQuat;
  89511. /**
  89512. * Specifies if the physics imposter is disposed
  89513. */
  89514. readonly isDisposed: boolean;
  89515. /**
  89516. * Gets the mass of the physics imposter
  89517. */
  89518. mass: number;
  89519. /**
  89520. * Gets the coefficient of friction
  89521. */
  89522. /**
  89523. * Sets the coefficient of friction
  89524. */
  89525. friction: number;
  89526. /**
  89527. * Gets the coefficient of restitution
  89528. */
  89529. /**
  89530. * Sets the coefficient of restitution
  89531. */
  89532. restitution: number;
  89533. /**
  89534. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  89535. */
  89536. /**
  89537. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  89538. */
  89539. pressure: number;
  89540. /**
  89541. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89542. */
  89543. /**
  89544. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89545. */
  89546. stiffness: number;
  89547. /**
  89548. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89549. */
  89550. /**
  89551. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89552. */
  89553. velocityIterations: number;
  89554. /**
  89555. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89556. */
  89557. /**
  89558. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89559. */
  89560. positionIterations: number;
  89561. /**
  89562. * The unique id of the physics imposter
  89563. * set by the physics engine when adding this impostor to the array
  89564. */
  89565. uniqueId: number;
  89566. /**
  89567. * @hidden
  89568. */
  89569. soft: boolean;
  89570. /**
  89571. * @hidden
  89572. */
  89573. segments: number;
  89574. private _joints;
  89575. /**
  89576. * Initializes the physics imposter
  89577. * @param object The physics-enabled object used as the physics imposter
  89578. * @param type The type of the physics imposter
  89579. * @param _options The options for the physics imposter
  89580. * @param _scene The Babylon scene
  89581. */
  89582. constructor(
  89583. /**
  89584. * The physics-enabled object used as the physics imposter
  89585. */
  89586. object: IPhysicsEnabledObject,
  89587. /**
  89588. * The type of the physics imposter
  89589. */
  89590. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  89591. /**
  89592. * This function will completly initialize this impostor.
  89593. * It will create a new body - but only if this mesh has no parent.
  89594. * If it has, this impostor will not be used other than to define the impostor
  89595. * of the child mesh.
  89596. * @hidden
  89597. */
  89598. _init(): void;
  89599. private _getPhysicsParent;
  89600. /**
  89601. * Should a new body be generated.
  89602. * @returns boolean specifying if body initialization is required
  89603. */
  89604. isBodyInitRequired(): boolean;
  89605. /**
  89606. * Sets the updated scaling
  89607. * @param updated Specifies if the scaling is updated
  89608. */
  89609. setScalingUpdated(): void;
  89610. /**
  89611. * Force a regeneration of this or the parent's impostor's body.
  89612. * Use under cautious - This will remove all joints already implemented.
  89613. */
  89614. forceUpdate(): void;
  89615. /**
  89616. * Gets the body that holds this impostor. Either its own, or its parent.
  89617. */
  89618. /**
  89619. * Set the physics body. Used mainly by the physics engine/plugin
  89620. */
  89621. physicsBody: any;
  89622. /**
  89623. * Get the parent of the physics imposter
  89624. * @returns Physics imposter or null
  89625. */
  89626. /**
  89627. * Sets the parent of the physics imposter
  89628. */
  89629. parent: Nullable<PhysicsImpostor>;
  89630. /**
  89631. * Resets the update flags
  89632. */
  89633. resetUpdateFlags(): void;
  89634. /**
  89635. * Gets the object extend size
  89636. * @returns the object extend size
  89637. */
  89638. getObjectExtendSize(): Vector3;
  89639. /**
  89640. * Gets the object center
  89641. * @returns The object center
  89642. */
  89643. getObjectCenter(): Vector3;
  89644. /**
  89645. * Get a specific parametes from the options parameter
  89646. * @param paramName The object parameter name
  89647. * @returns The object parameter
  89648. */
  89649. getParam(paramName: string): any;
  89650. /**
  89651. * Sets a specific parameter in the options given to the physics plugin
  89652. * @param paramName The parameter name
  89653. * @param value The value of the parameter
  89654. */
  89655. setParam(paramName: string, value: number): void;
  89656. /**
  89657. * Specifically change the body's mass option. Won't recreate the physics body object
  89658. * @param mass The mass of the physics imposter
  89659. */
  89660. setMass(mass: number): void;
  89661. /**
  89662. * Gets the linear velocity
  89663. * @returns linear velocity or null
  89664. */
  89665. getLinearVelocity(): Nullable<Vector3>;
  89666. /**
  89667. * Sets the linear velocity
  89668. * @param velocity linear velocity or null
  89669. */
  89670. setLinearVelocity(velocity: Nullable<Vector3>): void;
  89671. /**
  89672. * Gets the angular velocity
  89673. * @returns angular velocity or null
  89674. */
  89675. getAngularVelocity(): Nullable<Vector3>;
  89676. /**
  89677. * Sets the angular velocity
  89678. * @param velocity The velocity or null
  89679. */
  89680. setAngularVelocity(velocity: Nullable<Vector3>): void;
  89681. /**
  89682. * Execute a function with the physics plugin native code
  89683. * Provide a function the will have two variables - the world object and the physics body object
  89684. * @param func The function to execute with the physics plugin native code
  89685. */
  89686. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  89687. /**
  89688. * Register a function that will be executed before the physics world is stepping forward
  89689. * @param func The function to execute before the physics world is stepped forward
  89690. */
  89691. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89692. /**
  89693. * Unregister a function that will be executed before the physics world is stepping forward
  89694. * @param func The function to execute before the physics world is stepped forward
  89695. */
  89696. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89697. /**
  89698. * Register a function that will be executed after the physics step
  89699. * @param func The function to execute after physics step
  89700. */
  89701. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89702. /**
  89703. * Unregisters a function that will be executed after the physics step
  89704. * @param func The function to execute after physics step
  89705. */
  89706. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89707. /**
  89708. * register a function that will be executed when this impostor collides against a different body
  89709. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  89710. * @param func Callback that is executed on collision
  89711. */
  89712. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  89713. /**
  89714. * Unregisters the physics imposter on contact
  89715. * @param collideAgainst The physics object to collide against
  89716. * @param func Callback to execute on collision
  89717. */
  89718. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  89719. private _tmpQuat;
  89720. private _tmpQuat2;
  89721. /**
  89722. * Get the parent rotation
  89723. * @returns The parent rotation
  89724. */
  89725. getParentsRotation(): Quaternion;
  89726. /**
  89727. * this function is executed by the physics engine.
  89728. */
  89729. beforeStep: () => void;
  89730. /**
  89731. * this function is executed by the physics engine
  89732. */
  89733. afterStep: () => void;
  89734. /**
  89735. * Legacy collision detection event support
  89736. */
  89737. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  89738. /**
  89739. * event and body object due to cannon's event-based architecture.
  89740. */
  89741. onCollide: (e: {
  89742. body: any;
  89743. }) => void;
  89744. /**
  89745. * Apply a force
  89746. * @param force The force to apply
  89747. * @param contactPoint The contact point for the force
  89748. * @returns The physics imposter
  89749. */
  89750. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  89751. /**
  89752. * Apply an impulse
  89753. * @param force The impulse force
  89754. * @param contactPoint The contact point for the impulse force
  89755. * @returns The physics imposter
  89756. */
  89757. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  89758. /**
  89759. * A help function to create a joint
  89760. * @param otherImpostor A physics imposter used to create a joint
  89761. * @param jointType The type of joint
  89762. * @param jointData The data for the joint
  89763. * @returns The physics imposter
  89764. */
  89765. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  89766. /**
  89767. * Add a joint to this impostor with a different impostor
  89768. * @param otherImpostor A physics imposter used to add a joint
  89769. * @param joint The joint to add
  89770. * @returns The physics imposter
  89771. */
  89772. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  89773. /**
  89774. * Add an anchor to a cloth impostor
  89775. * @param otherImpostor rigid impostor to anchor to
  89776. * @param width ratio across width from 0 to 1
  89777. * @param height ratio up height from 0 to 1
  89778. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  89779. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  89780. * @returns impostor the soft imposter
  89781. */
  89782. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89783. /**
  89784. * Add a hook to a rope impostor
  89785. * @param otherImpostor rigid impostor to anchor to
  89786. * @param length ratio across rope from 0 to 1
  89787. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  89788. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  89789. * @returns impostor the rope imposter
  89790. */
  89791. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89792. /**
  89793. * Will keep this body still, in a sleep mode.
  89794. * @returns the physics imposter
  89795. */
  89796. sleep(): PhysicsImpostor;
  89797. /**
  89798. * Wake the body up.
  89799. * @returns The physics imposter
  89800. */
  89801. wakeUp(): PhysicsImpostor;
  89802. /**
  89803. * Clones the physics imposter
  89804. * @param newObject The physics imposter clones to this physics-enabled object
  89805. * @returns A nullable physics imposter
  89806. */
  89807. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89808. /**
  89809. * Disposes the physics imposter
  89810. */
  89811. dispose(): void;
  89812. /**
  89813. * Sets the delta position
  89814. * @param position The delta position amount
  89815. */
  89816. setDeltaPosition(position: Vector3): void;
  89817. /**
  89818. * Sets the delta rotation
  89819. * @param rotation The delta rotation amount
  89820. */
  89821. setDeltaRotation(rotation: Quaternion): void;
  89822. /**
  89823. * Gets the box size of the physics imposter and stores the result in the input parameter
  89824. * @param result Stores the box size
  89825. * @returns The physics imposter
  89826. */
  89827. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  89828. /**
  89829. * Gets the radius of the physics imposter
  89830. * @returns Radius of the physics imposter
  89831. */
  89832. getRadius(): number;
  89833. /**
  89834. * Sync a bone with this impostor
  89835. * @param bone The bone to sync to the impostor.
  89836. * @param boneMesh The mesh that the bone is influencing.
  89837. * @param jointPivot The pivot of the joint / bone in local space.
  89838. * @param distToJoint Optional distance from the impostor to the joint.
  89839. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  89840. */
  89841. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  89842. /**
  89843. * Sync impostor to a bone
  89844. * @param bone The bone that the impostor will be synced to.
  89845. * @param boneMesh The mesh that the bone is influencing.
  89846. * @param jointPivot The pivot of the joint / bone in local space.
  89847. * @param distToJoint Optional distance from the impostor to the joint.
  89848. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  89849. * @param boneAxis Optional vector3 axis the bone is aligned with
  89850. */
  89851. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  89852. /**
  89853. * No-Imposter type
  89854. */
  89855. static NoImpostor: number;
  89856. /**
  89857. * Sphere-Imposter type
  89858. */
  89859. static SphereImpostor: number;
  89860. /**
  89861. * Box-Imposter type
  89862. */
  89863. static BoxImpostor: number;
  89864. /**
  89865. * Plane-Imposter type
  89866. */
  89867. static PlaneImpostor: number;
  89868. /**
  89869. * Mesh-imposter type
  89870. */
  89871. static MeshImpostor: number;
  89872. /**
  89873. * Capsule-Impostor type (Ammo.js plugin only)
  89874. */
  89875. static CapsuleImpostor: number;
  89876. /**
  89877. * Cylinder-Imposter type
  89878. */
  89879. static CylinderImpostor: number;
  89880. /**
  89881. * Particle-Imposter type
  89882. */
  89883. static ParticleImpostor: number;
  89884. /**
  89885. * Heightmap-Imposter type
  89886. */
  89887. static HeightmapImpostor: number;
  89888. /**
  89889. * ConvexHull-Impostor type (Ammo.js plugin only)
  89890. */
  89891. static ConvexHullImpostor: number;
  89892. /**
  89893. * Rope-Imposter type
  89894. */
  89895. static RopeImpostor: number;
  89896. /**
  89897. * Cloth-Imposter type
  89898. */
  89899. static ClothImpostor: number;
  89900. /**
  89901. * Softbody-Imposter type
  89902. */
  89903. static SoftbodyImpostor: number;
  89904. }
  89905. }
  89906. declare module BABYLON {
  89907. /**
  89908. * @hidden
  89909. **/
  89910. export class _CreationDataStorage {
  89911. closePath?: boolean;
  89912. closeArray?: boolean;
  89913. idx: number[];
  89914. dashSize: number;
  89915. gapSize: number;
  89916. path3D: Path3D;
  89917. pathArray: Vector3[][];
  89918. arc: number;
  89919. radius: number;
  89920. cap: number;
  89921. tessellation: number;
  89922. }
  89923. /**
  89924. * @hidden
  89925. **/
  89926. class _InstanceDataStorage {
  89927. visibleInstances: any;
  89928. batchCache: _InstancesBatch;
  89929. instancesBufferSize: number;
  89930. instancesBuffer: Nullable<Buffer>;
  89931. instancesData: Float32Array;
  89932. overridenInstanceCount: number;
  89933. isFrozen: boolean;
  89934. previousBatch: Nullable<_InstancesBatch>;
  89935. hardwareInstancedRendering: boolean;
  89936. sideOrientation: number;
  89937. }
  89938. /**
  89939. * @hidden
  89940. **/
  89941. export class _InstancesBatch {
  89942. mustReturn: boolean;
  89943. visibleInstances: Nullable<InstancedMesh[]>[];
  89944. renderSelf: boolean[];
  89945. hardwareInstancedRendering: boolean[];
  89946. }
  89947. /**
  89948. * Class used to represent renderable models
  89949. */
  89950. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  89951. /**
  89952. * Mesh side orientation : usually the external or front surface
  89953. */
  89954. static readonly FRONTSIDE: number;
  89955. /**
  89956. * Mesh side orientation : usually the internal or back surface
  89957. */
  89958. static readonly BACKSIDE: number;
  89959. /**
  89960. * Mesh side orientation : both internal and external or front and back surfaces
  89961. */
  89962. static readonly DOUBLESIDE: number;
  89963. /**
  89964. * Mesh side orientation : by default, `FRONTSIDE`
  89965. */
  89966. static readonly DEFAULTSIDE: number;
  89967. /**
  89968. * Mesh cap setting : no cap
  89969. */
  89970. static readonly NO_CAP: number;
  89971. /**
  89972. * Mesh cap setting : one cap at the beginning of the mesh
  89973. */
  89974. static readonly CAP_START: number;
  89975. /**
  89976. * Mesh cap setting : one cap at the end of the mesh
  89977. */
  89978. static readonly CAP_END: number;
  89979. /**
  89980. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  89981. */
  89982. static readonly CAP_ALL: number;
  89983. /**
  89984. * Mesh pattern setting : no flip or rotate
  89985. */
  89986. static readonly NO_FLIP: number;
  89987. /**
  89988. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  89989. */
  89990. static readonly FLIP_TILE: number;
  89991. /**
  89992. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  89993. */
  89994. static readonly ROTATE_TILE: number;
  89995. /**
  89996. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  89997. */
  89998. static readonly FLIP_ROW: number;
  89999. /**
  90000. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  90001. */
  90002. static readonly ROTATE_ROW: number;
  90003. /**
  90004. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  90005. */
  90006. static readonly FLIP_N_ROTATE_TILE: number;
  90007. /**
  90008. * Mesh pattern setting : rotate pattern and rotate
  90009. */
  90010. static readonly FLIP_N_ROTATE_ROW: number;
  90011. /**
  90012. * Mesh tile positioning : part tiles same on left/right or top/bottom
  90013. */
  90014. static readonly CENTER: number;
  90015. /**
  90016. * Mesh tile positioning : part tiles on left
  90017. */
  90018. static readonly LEFT: number;
  90019. /**
  90020. * Mesh tile positioning : part tiles on right
  90021. */
  90022. static readonly RIGHT: number;
  90023. /**
  90024. * Mesh tile positioning : part tiles on top
  90025. */
  90026. static readonly TOP: number;
  90027. /**
  90028. * Mesh tile positioning : part tiles on bottom
  90029. */
  90030. static readonly BOTTOM: number;
  90031. /**
  90032. * Gets the default side orientation.
  90033. * @param orientation the orientation to value to attempt to get
  90034. * @returns the default orientation
  90035. * @hidden
  90036. */
  90037. static _GetDefaultSideOrientation(orientation?: number): number;
  90038. private _internalMeshDataInfo;
  90039. /**
  90040. * An event triggered before rendering the mesh
  90041. */
  90042. readonly onBeforeRenderObservable: Observable<Mesh>;
  90043. /**
  90044. * An event triggered before binding the mesh
  90045. */
  90046. readonly onBeforeBindObservable: Observable<Mesh>;
  90047. /**
  90048. * An event triggered after rendering the mesh
  90049. */
  90050. readonly onAfterRenderObservable: Observable<Mesh>;
  90051. /**
  90052. * An event triggered before drawing the mesh
  90053. */
  90054. readonly onBeforeDrawObservable: Observable<Mesh>;
  90055. private _onBeforeDrawObserver;
  90056. /**
  90057. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  90058. */
  90059. onBeforeDraw: () => void;
  90060. readonly hasInstances: boolean;
  90061. /**
  90062. * Gets the delay loading state of the mesh (when delay loading is turned on)
  90063. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  90064. */
  90065. delayLoadState: number;
  90066. /**
  90067. * Gets the list of instances created from this mesh
  90068. * it is not supposed to be modified manually.
  90069. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  90070. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90071. */
  90072. instances: InstancedMesh[];
  90073. /**
  90074. * Gets the file containing delay loading data for this mesh
  90075. */
  90076. delayLoadingFile: string;
  90077. /** @hidden */
  90078. _binaryInfo: any;
  90079. /**
  90080. * User defined function used to change how LOD level selection is done
  90081. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90082. */
  90083. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  90084. /**
  90085. * Gets or sets the morph target manager
  90086. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90087. */
  90088. morphTargetManager: Nullable<MorphTargetManager>;
  90089. /** @hidden */
  90090. _creationDataStorage: Nullable<_CreationDataStorage>;
  90091. /** @hidden */
  90092. _geometry: Nullable<Geometry>;
  90093. /** @hidden */
  90094. _delayInfo: Array<string>;
  90095. /** @hidden */
  90096. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  90097. /** @hidden */
  90098. _instanceDataStorage: _InstanceDataStorage;
  90099. private _effectiveMaterial;
  90100. /** @hidden */
  90101. _shouldGenerateFlatShading: boolean;
  90102. /** @hidden */
  90103. _originalBuilderSideOrientation: number;
  90104. /**
  90105. * Use this property to change the original side orientation defined at construction time
  90106. */
  90107. overrideMaterialSideOrientation: Nullable<number>;
  90108. /**
  90109. * Gets the source mesh (the one used to clone this one from)
  90110. */
  90111. readonly source: Nullable<Mesh>;
  90112. /**
  90113. * Gets or sets a boolean indicating that this mesh does not use index buffer
  90114. */
  90115. isUnIndexed: boolean;
  90116. /**
  90117. * @constructor
  90118. * @param name The value used by scene.getMeshByName() to do a lookup.
  90119. * @param scene The scene to add this mesh to.
  90120. * @param parent The parent of this mesh, if it has one
  90121. * @param source An optional Mesh from which geometry is shared, cloned.
  90122. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90123. * When false, achieved by calling a clone(), also passing False.
  90124. * This will make creation of children, recursive.
  90125. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  90126. */
  90127. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  90128. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  90129. /**
  90130. * Gets the class name
  90131. * @returns the string "Mesh".
  90132. */
  90133. getClassName(): string;
  90134. /** @hidden */
  90135. readonly _isMesh: boolean;
  90136. /**
  90137. * Returns a description of this mesh
  90138. * @param fullDetails define if full details about this mesh must be used
  90139. * @returns a descriptive string representing this mesh
  90140. */
  90141. toString(fullDetails?: boolean): string;
  90142. /** @hidden */
  90143. _unBindEffect(): void;
  90144. /**
  90145. * Gets a boolean indicating if this mesh has LOD
  90146. */
  90147. readonly hasLODLevels: boolean;
  90148. /**
  90149. * Gets the list of MeshLODLevel associated with the current mesh
  90150. * @returns an array of MeshLODLevel
  90151. */
  90152. getLODLevels(): MeshLODLevel[];
  90153. private _sortLODLevels;
  90154. /**
  90155. * Add a mesh as LOD level triggered at the given distance.
  90156. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90157. * @param distance The distance from the center of the object to show this level
  90158. * @param mesh The mesh to be added as LOD level (can be null)
  90159. * @return This mesh (for chaining)
  90160. */
  90161. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  90162. /**
  90163. * Returns the LOD level mesh at the passed distance or null if not found.
  90164. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90165. * @param distance The distance from the center of the object to show this level
  90166. * @returns a Mesh or `null`
  90167. */
  90168. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  90169. /**
  90170. * Remove a mesh from the LOD array
  90171. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90172. * @param mesh defines the mesh to be removed
  90173. * @return This mesh (for chaining)
  90174. */
  90175. removeLODLevel(mesh: Mesh): Mesh;
  90176. /**
  90177. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  90178. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90179. * @param camera defines the camera to use to compute distance
  90180. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  90181. * @return This mesh (for chaining)
  90182. */
  90183. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  90184. /**
  90185. * Gets the mesh internal Geometry object
  90186. */
  90187. readonly geometry: Nullable<Geometry>;
  90188. /**
  90189. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  90190. * @returns the total number of vertices
  90191. */
  90192. getTotalVertices(): number;
  90193. /**
  90194. * Returns the content of an associated vertex buffer
  90195. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90196. * - VertexBuffer.PositionKind
  90197. * - VertexBuffer.UVKind
  90198. * - VertexBuffer.UV2Kind
  90199. * - VertexBuffer.UV3Kind
  90200. * - VertexBuffer.UV4Kind
  90201. * - VertexBuffer.UV5Kind
  90202. * - VertexBuffer.UV6Kind
  90203. * - VertexBuffer.ColorKind
  90204. * - VertexBuffer.MatricesIndicesKind
  90205. * - VertexBuffer.MatricesIndicesExtraKind
  90206. * - VertexBuffer.MatricesWeightsKind
  90207. * - VertexBuffer.MatricesWeightsExtraKind
  90208. * @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
  90209. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  90210. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  90211. */
  90212. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90213. /**
  90214. * Returns the mesh VertexBuffer object from the requested `kind`
  90215. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90216. * - VertexBuffer.PositionKind
  90217. * - VertexBuffer.NormalKind
  90218. * - VertexBuffer.UVKind
  90219. * - VertexBuffer.UV2Kind
  90220. * - VertexBuffer.UV3Kind
  90221. * - VertexBuffer.UV4Kind
  90222. * - VertexBuffer.UV5Kind
  90223. * - VertexBuffer.UV6Kind
  90224. * - VertexBuffer.ColorKind
  90225. * - VertexBuffer.MatricesIndicesKind
  90226. * - VertexBuffer.MatricesIndicesExtraKind
  90227. * - VertexBuffer.MatricesWeightsKind
  90228. * - VertexBuffer.MatricesWeightsExtraKind
  90229. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  90230. */
  90231. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90232. /**
  90233. * Tests if a specific vertex buffer is associated with this mesh
  90234. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90235. * - VertexBuffer.PositionKind
  90236. * - VertexBuffer.NormalKind
  90237. * - VertexBuffer.UVKind
  90238. * - VertexBuffer.UV2Kind
  90239. * - VertexBuffer.UV3Kind
  90240. * - VertexBuffer.UV4Kind
  90241. * - VertexBuffer.UV5Kind
  90242. * - VertexBuffer.UV6Kind
  90243. * - VertexBuffer.ColorKind
  90244. * - VertexBuffer.MatricesIndicesKind
  90245. * - VertexBuffer.MatricesIndicesExtraKind
  90246. * - VertexBuffer.MatricesWeightsKind
  90247. * - VertexBuffer.MatricesWeightsExtraKind
  90248. * @returns a boolean
  90249. */
  90250. isVerticesDataPresent(kind: string): boolean;
  90251. /**
  90252. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  90253. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90254. * - VertexBuffer.PositionKind
  90255. * - VertexBuffer.UVKind
  90256. * - VertexBuffer.UV2Kind
  90257. * - VertexBuffer.UV3Kind
  90258. * - VertexBuffer.UV4Kind
  90259. * - VertexBuffer.UV5Kind
  90260. * - VertexBuffer.UV6Kind
  90261. * - VertexBuffer.ColorKind
  90262. * - VertexBuffer.MatricesIndicesKind
  90263. * - VertexBuffer.MatricesIndicesExtraKind
  90264. * - VertexBuffer.MatricesWeightsKind
  90265. * - VertexBuffer.MatricesWeightsExtraKind
  90266. * @returns a boolean
  90267. */
  90268. isVertexBufferUpdatable(kind: string): boolean;
  90269. /**
  90270. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  90271. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90272. * - VertexBuffer.PositionKind
  90273. * - VertexBuffer.NormalKind
  90274. * - VertexBuffer.UVKind
  90275. * - VertexBuffer.UV2Kind
  90276. * - VertexBuffer.UV3Kind
  90277. * - VertexBuffer.UV4Kind
  90278. * - VertexBuffer.UV5Kind
  90279. * - VertexBuffer.UV6Kind
  90280. * - VertexBuffer.ColorKind
  90281. * - VertexBuffer.MatricesIndicesKind
  90282. * - VertexBuffer.MatricesIndicesExtraKind
  90283. * - VertexBuffer.MatricesWeightsKind
  90284. * - VertexBuffer.MatricesWeightsExtraKind
  90285. * @returns an array of strings
  90286. */
  90287. getVerticesDataKinds(): string[];
  90288. /**
  90289. * Returns a positive integer : the total number of indices in this mesh geometry.
  90290. * @returns the numner of indices or zero if the mesh has no geometry.
  90291. */
  90292. getTotalIndices(): number;
  90293. /**
  90294. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90295. * @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.
  90296. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90297. * @returns the indices array or an empty array if the mesh has no geometry
  90298. */
  90299. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90300. readonly isBlocked: boolean;
  90301. /**
  90302. * Determine if the current mesh is ready to be rendered
  90303. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90304. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  90305. * @returns true if all associated assets are ready (material, textures, shaders)
  90306. */
  90307. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  90308. /**
  90309. * 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.
  90310. */
  90311. readonly areNormalsFrozen: boolean;
  90312. /**
  90313. * 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.
  90314. * @returns the current mesh
  90315. */
  90316. freezeNormals(): Mesh;
  90317. /**
  90318. * 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
  90319. * @returns the current mesh
  90320. */
  90321. unfreezeNormals(): Mesh;
  90322. /**
  90323. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  90324. */
  90325. overridenInstanceCount: number;
  90326. /** @hidden */
  90327. _preActivate(): Mesh;
  90328. /** @hidden */
  90329. _preActivateForIntermediateRendering(renderId: number): Mesh;
  90330. /** @hidden */
  90331. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  90332. /**
  90333. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90334. * This means the mesh underlying bounding box and sphere are recomputed.
  90335. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90336. * @returns the current mesh
  90337. */
  90338. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  90339. /** @hidden */
  90340. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  90341. /**
  90342. * This function will subdivide the mesh into multiple submeshes
  90343. * @param count defines the expected number of submeshes
  90344. */
  90345. subdivide(count: number): void;
  90346. /**
  90347. * Copy a FloatArray into a specific associated vertex buffer
  90348. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90349. * - VertexBuffer.PositionKind
  90350. * - VertexBuffer.UVKind
  90351. * - VertexBuffer.UV2Kind
  90352. * - VertexBuffer.UV3Kind
  90353. * - VertexBuffer.UV4Kind
  90354. * - VertexBuffer.UV5Kind
  90355. * - VertexBuffer.UV6Kind
  90356. * - VertexBuffer.ColorKind
  90357. * - VertexBuffer.MatricesIndicesKind
  90358. * - VertexBuffer.MatricesIndicesExtraKind
  90359. * - VertexBuffer.MatricesWeightsKind
  90360. * - VertexBuffer.MatricesWeightsExtraKind
  90361. * @param data defines the data source
  90362. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90363. * @param stride defines the data stride size (can be null)
  90364. * @returns the current mesh
  90365. */
  90366. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90367. /**
  90368. * Flags an associated vertex buffer as updatable
  90369. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  90370. * - VertexBuffer.PositionKind
  90371. * - VertexBuffer.UVKind
  90372. * - VertexBuffer.UV2Kind
  90373. * - VertexBuffer.UV3Kind
  90374. * - VertexBuffer.UV4Kind
  90375. * - VertexBuffer.UV5Kind
  90376. * - VertexBuffer.UV6Kind
  90377. * - VertexBuffer.ColorKind
  90378. * - VertexBuffer.MatricesIndicesKind
  90379. * - VertexBuffer.MatricesIndicesExtraKind
  90380. * - VertexBuffer.MatricesWeightsKind
  90381. * - VertexBuffer.MatricesWeightsExtraKind
  90382. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90383. */
  90384. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  90385. /**
  90386. * Sets the mesh global Vertex Buffer
  90387. * @param buffer defines the buffer to use
  90388. * @returns the current mesh
  90389. */
  90390. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  90391. /**
  90392. * Update a specific associated vertex buffer
  90393. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90394. * - VertexBuffer.PositionKind
  90395. * - VertexBuffer.UVKind
  90396. * - VertexBuffer.UV2Kind
  90397. * - VertexBuffer.UV3Kind
  90398. * - VertexBuffer.UV4Kind
  90399. * - VertexBuffer.UV5Kind
  90400. * - VertexBuffer.UV6Kind
  90401. * - VertexBuffer.ColorKind
  90402. * - VertexBuffer.MatricesIndicesKind
  90403. * - VertexBuffer.MatricesIndicesExtraKind
  90404. * - VertexBuffer.MatricesWeightsKind
  90405. * - VertexBuffer.MatricesWeightsExtraKind
  90406. * @param data defines the data source
  90407. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90408. * @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)
  90409. * @returns the current mesh
  90410. */
  90411. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90412. /**
  90413. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  90414. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  90415. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  90416. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  90417. * @returns the current mesh
  90418. */
  90419. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  90420. /**
  90421. * Creates a un-shared specific occurence of the geometry for the mesh.
  90422. * @returns the current mesh
  90423. */
  90424. makeGeometryUnique(): Mesh;
  90425. /**
  90426. * Set the index buffer of this mesh
  90427. * @param indices defines the source data
  90428. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  90429. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  90430. * @returns the current mesh
  90431. */
  90432. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  90433. /**
  90434. * Update the current index buffer
  90435. * @param indices defines the source data
  90436. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90437. * @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)
  90438. * @returns the current mesh
  90439. */
  90440. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90441. /**
  90442. * Invert the geometry to move from a right handed system to a left handed one.
  90443. * @returns the current mesh
  90444. */
  90445. toLeftHanded(): Mesh;
  90446. /** @hidden */
  90447. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90448. /** @hidden */
  90449. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90450. /**
  90451. * Registers for this mesh a javascript function called just before the rendering process
  90452. * @param func defines the function to call before rendering this mesh
  90453. * @returns the current mesh
  90454. */
  90455. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90456. /**
  90457. * Disposes a previously registered javascript function called before the rendering
  90458. * @param func defines the function to remove
  90459. * @returns the current mesh
  90460. */
  90461. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90462. /**
  90463. * Registers for this mesh a javascript function called just after the rendering is complete
  90464. * @param func defines the function to call after rendering this mesh
  90465. * @returns the current mesh
  90466. */
  90467. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90468. /**
  90469. * Disposes a previously registered javascript function called after the rendering.
  90470. * @param func defines the function to remove
  90471. * @returns the current mesh
  90472. */
  90473. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90474. /** @hidden */
  90475. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  90476. /** @hidden */
  90477. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  90478. /** @hidden */
  90479. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  90480. /** @hidden */
  90481. _rebuild(): void;
  90482. /** @hidden */
  90483. _freeze(): void;
  90484. /** @hidden */
  90485. _unFreeze(): void;
  90486. /**
  90487. * 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
  90488. * @param subMesh defines the subMesh to render
  90489. * @param enableAlphaMode defines if alpha mode can be changed
  90490. * @returns the current mesh
  90491. */
  90492. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  90493. private _onBeforeDraw;
  90494. /**
  90495. * Renormalize the mesh and patch it up if there are no weights
  90496. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  90497. * However in the case of zero weights then we set just a single influence to 1.
  90498. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  90499. */
  90500. cleanMatrixWeights(): void;
  90501. private normalizeSkinFourWeights;
  90502. private normalizeSkinWeightsAndExtra;
  90503. /**
  90504. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  90505. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  90506. * the user know there was an issue with importing the mesh
  90507. * @returns a validation object with skinned, valid and report string
  90508. */
  90509. validateSkinning(): {
  90510. skinned: boolean;
  90511. valid: boolean;
  90512. report: string;
  90513. };
  90514. /** @hidden */
  90515. _checkDelayState(): Mesh;
  90516. private _queueLoad;
  90517. /**
  90518. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90519. * A mesh is in the frustum if its bounding box intersects the frustum
  90520. * @param frustumPlanes defines the frustum to test
  90521. * @returns true if the mesh is in the frustum planes
  90522. */
  90523. isInFrustum(frustumPlanes: Plane[]): boolean;
  90524. /**
  90525. * Sets the mesh material by the material or multiMaterial `id` property
  90526. * @param id is a string identifying the material or the multiMaterial
  90527. * @returns the current mesh
  90528. */
  90529. setMaterialByID(id: string): Mesh;
  90530. /**
  90531. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  90532. * @returns an array of IAnimatable
  90533. */
  90534. getAnimatables(): IAnimatable[];
  90535. /**
  90536. * Modifies the mesh geometry according to the passed transformation matrix.
  90537. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  90538. * The mesh normals are modified using the same transformation.
  90539. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90540. * @param transform defines the transform matrix to use
  90541. * @see http://doc.babylonjs.com/resources/baking_transformations
  90542. * @returns the current mesh
  90543. */
  90544. bakeTransformIntoVertices(transform: Matrix): Mesh;
  90545. /**
  90546. * Modifies the mesh geometry according to its own current World Matrix.
  90547. * The mesh World Matrix is then reset.
  90548. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  90549. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90550. * @see http://doc.babylonjs.com/resources/baking_transformations
  90551. * @returns the current mesh
  90552. */
  90553. bakeCurrentTransformIntoVertices(): Mesh;
  90554. /** @hidden */
  90555. readonly _positions: Nullable<Vector3[]>;
  90556. /** @hidden */
  90557. _resetPointsArrayCache(): Mesh;
  90558. /** @hidden */
  90559. _generatePointsArray(): boolean;
  90560. /**
  90561. * Returns a new Mesh object generated from the current mesh properties.
  90562. * This method must not get confused with createInstance()
  90563. * @param name is a string, the name given to the new mesh
  90564. * @param newParent can be any Node object (default `null`)
  90565. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  90566. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  90567. * @returns a new mesh
  90568. */
  90569. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  90570. /**
  90571. * Releases resources associated with this mesh.
  90572. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90573. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90574. */
  90575. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90576. /**
  90577. * Modifies the mesh geometry according to a displacement map.
  90578. * 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.
  90579. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90580. * @param url is a string, the URL from the image file is to be downloaded.
  90581. * @param minHeight is the lower limit of the displacement.
  90582. * @param maxHeight is the upper limit of the displacement.
  90583. * @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.
  90584. * @param uvOffset is an optional vector2 used to offset UV.
  90585. * @param uvScale is an optional vector2 used to scale UV.
  90586. * @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.
  90587. * @returns the Mesh.
  90588. */
  90589. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90590. /**
  90591. * Modifies the mesh geometry according to a displacementMap buffer.
  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 buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  90595. * @param heightMapWidth is the width of the buffer image.
  90596. * @param heightMapHeight is the height of the buffer image.
  90597. * @param minHeight is the lower limit of the displacement.
  90598. * @param maxHeight is the upper limit of the displacement.
  90599. * @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.
  90600. * @param uvOffset is an optional vector2 used to offset UV.
  90601. * @param uvScale is an optional vector2 used to scale UV.
  90602. * @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.
  90603. * @returns the Mesh.
  90604. */
  90605. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90606. /**
  90607. * Modify the mesh to get a flat shading rendering.
  90608. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  90609. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  90610. * @returns current mesh
  90611. */
  90612. convertToFlatShadedMesh(): Mesh;
  90613. /**
  90614. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  90615. * In other words, more vertices, no more indices and a single bigger VBO.
  90616. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  90617. * @returns current mesh
  90618. */
  90619. convertToUnIndexedMesh(): Mesh;
  90620. /**
  90621. * Inverses facet orientations.
  90622. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90623. * @param flipNormals will also inverts the normals
  90624. * @returns current mesh
  90625. */
  90626. flipFaces(flipNormals?: boolean): Mesh;
  90627. /**
  90628. * Increase the number of facets and hence vertices in a mesh
  90629. * Vertex normals are interpolated from existing vertex normals
  90630. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90631. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  90632. */
  90633. increaseVertices(numberPerEdge: number): void;
  90634. /**
  90635. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  90636. * This will undo any application of covertToFlatShadedMesh
  90637. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90638. */
  90639. forceSharedVertices(): void;
  90640. /** @hidden */
  90641. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  90642. /** @hidden */
  90643. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  90644. /**
  90645. * Creates a new InstancedMesh object from the mesh model.
  90646. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90647. * @param name defines the name of the new instance
  90648. * @returns a new InstancedMesh
  90649. */
  90650. createInstance(name: string): InstancedMesh;
  90651. /**
  90652. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  90653. * After this call, all the mesh instances have the same submeshes than the current mesh.
  90654. * @returns the current mesh
  90655. */
  90656. synchronizeInstances(): Mesh;
  90657. /**
  90658. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  90659. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  90660. * This should be used together with the simplification to avoid disappearing triangles.
  90661. * @param successCallback an optional success callback to be called after the optimization finished.
  90662. * @returns the current mesh
  90663. */
  90664. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  90665. /**
  90666. * Serialize current mesh
  90667. * @param serializationObject defines the object which will receive the serialization data
  90668. */
  90669. serialize(serializationObject: any): void;
  90670. /** @hidden */
  90671. _syncGeometryWithMorphTargetManager(): void;
  90672. /** @hidden */
  90673. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  90674. /**
  90675. * Returns a new Mesh object parsed from the source provided.
  90676. * @param parsedMesh is the source
  90677. * @param scene defines the hosting scene
  90678. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  90679. * @returns a new Mesh
  90680. */
  90681. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  90682. /**
  90683. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  90684. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90685. * @param name defines the name of the mesh to create
  90686. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  90687. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  90688. * @param closePath creates a seam between the first and the last points of each path of the path array
  90689. * @param offset is taken in account only if the `pathArray` is containing a single path
  90690. * @param scene defines the hosting scene
  90691. * @param updatable defines if the mesh must be flagged as updatable
  90692. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90693. * @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)
  90694. * @returns a new Mesh
  90695. */
  90696. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90697. /**
  90698. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  90699. * @param name defines the name of the mesh to create
  90700. * @param radius sets the radius size (float) of the polygon (default 0.5)
  90701. * @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
  90702. * @param scene defines the hosting scene
  90703. * @param updatable defines if the mesh must be flagged as updatable
  90704. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90705. * @returns a new Mesh
  90706. */
  90707. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  90708. /**
  90709. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  90710. * @param name defines the name of the mesh to create
  90711. * @param size sets the size (float) of each box side (default 1)
  90712. * @param scene defines the hosting scene
  90713. * @param updatable defines if the mesh must be flagged as updatable
  90714. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90715. * @returns a new Mesh
  90716. */
  90717. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  90718. /**
  90719. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  90720. * @param name defines the name of the mesh to create
  90721. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  90722. * @param diameter sets the diameter size (float) of the sphere (default 1)
  90723. * @param scene defines the hosting scene
  90724. * @param updatable defines if the mesh must be flagged as updatable
  90725. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90726. * @returns a new Mesh
  90727. */
  90728. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90729. /**
  90730. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  90731. * @param name defines the name of the mesh to create
  90732. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  90733. * @param diameter sets the diameter size (float) of the sphere (default 1)
  90734. * @param scene defines the hosting scene
  90735. * @returns a new Mesh
  90736. */
  90737. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  90738. /**
  90739. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  90740. * @param name defines the name of the mesh to create
  90741. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  90742. * @param diameterTop set the top cap diameter (floats, default 1)
  90743. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  90744. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  90745. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  90746. * @param scene defines the hosting scene
  90747. * @param updatable defines if the mesh must be flagged as updatable
  90748. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90749. * @returns a new Mesh
  90750. */
  90751. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  90752. /**
  90753. * Creates a torus 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 diameter sets the diameter size (float) of the torus (default 1)
  90756. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  90757. * @param tessellation sets the number of torus sides (postive integer, default 16)
  90758. * @param scene defines the hosting scene
  90759. * @param updatable defines if the mesh must be flagged as updatable
  90760. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90761. * @returns a new Mesh
  90762. */
  90763. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90764. /**
  90765. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  90766. * @param name defines the name of the mesh to create
  90767. * @param radius sets the global radius size (float) of the torus knot (default 2)
  90768. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  90769. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  90770. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  90771. * @param p the number of windings on X axis (positive integers, default 2)
  90772. * @param q the number of windings on Y axis (positive integers, default 3)
  90773. * @param scene defines the hosting scene
  90774. * @param updatable defines if the mesh must be flagged as updatable
  90775. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90776. * @returns a new Mesh
  90777. */
  90778. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90779. /**
  90780. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  90781. * @param name defines the name of the mesh to create
  90782. * @param points is an array successive Vector3
  90783. * @param scene defines the hosting scene
  90784. * @param updatable defines if the mesh must be flagged as updatable
  90785. * @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).
  90786. * @returns a new Mesh
  90787. */
  90788. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  90789. /**
  90790. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  90791. * @param name defines the name of the mesh to create
  90792. * @param points is an array successive Vector3
  90793. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  90794. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  90795. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  90796. * @param scene defines the hosting scene
  90797. * @param updatable defines if the mesh must be flagged as updatable
  90798. * @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)
  90799. * @returns a new Mesh
  90800. */
  90801. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  90802. /**
  90803. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  90804. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  90805. * 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.
  90806. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90807. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90808. * Remember you can only change the shape positions, not their number when updating a polygon.
  90809. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  90810. * @param name defines the name of the mesh to create
  90811. * @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
  90812. * @param scene defines the hosting scene
  90813. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90814. * @param updatable defines if the mesh must be flagged as updatable
  90815. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90816. * @param earcutInjection can be used to inject your own earcut reference
  90817. * @returns a new Mesh
  90818. */
  90819. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  90820. /**
  90821. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  90822. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  90823. * @param name defines the name of the mesh to create
  90824. * @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
  90825. * @param depth defines the height of extrusion
  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 ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  90834. /**
  90835. * Creates an extruded shape mesh.
  90836. * 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
  90837. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90838. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90839. * @param name defines the name of the mesh to create
  90840. * @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
  90841. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90842. * @param scale is the value to scale the shape
  90843. * @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
  90844. * @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
  90845. * @param scene defines the hosting scene
  90846. * @param updatable defines if the mesh must be flagged as updatable
  90847. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90848. * @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)
  90849. * @returns a new Mesh
  90850. */
  90851. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90852. /**
  90853. * Creates an custom extruded shape mesh.
  90854. * The custom extrusion is a parametric shape.
  90855. * It has no predefined shape. Its final shape will depend on the input parameters.
  90856. * Please consider using the same method from the MeshBuilder class instead
  90857. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90858. * @param name defines the name of the mesh to create
  90859. * @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
  90860. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90861. * @param scaleFunction is a custom Javascript function called on each path point
  90862. * @param rotationFunction is a custom Javascript function called on each path point
  90863. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  90864. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  90865. * @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
  90866. * @param scene defines the hosting scene
  90867. * @param updatable defines if the mesh must be flagged as updatable
  90868. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90869. * @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)
  90870. * @returns a new Mesh
  90871. */
  90872. 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;
  90873. /**
  90874. * Creates lathe mesh.
  90875. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  90876. * Please consider using the same method from the MeshBuilder class instead
  90877. * @param name defines the name of the mesh to create
  90878. * @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
  90879. * @param radius is the radius value of the lathe
  90880. * @param tessellation is the side number of the lathe.
  90881. * @param scene defines the hosting scene
  90882. * @param updatable defines if the mesh must be flagged as updatable
  90883. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90884. * @returns a new Mesh
  90885. */
  90886. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90887. /**
  90888. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  90889. * @param name defines the name of the mesh to create
  90890. * @param size sets the size (float) of both sides of the plane at once (default 1)
  90891. * @param scene defines the hosting scene
  90892. * @param updatable defines if the mesh must be flagged as updatable
  90893. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90894. * @returns a new Mesh
  90895. */
  90896. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90897. /**
  90898. * Creates a ground mesh.
  90899. * Please consider using the same method from the MeshBuilder class instead
  90900. * @param name defines the name of the mesh to create
  90901. * @param width set the width of the ground
  90902. * @param height set the height of the ground
  90903. * @param subdivisions sets the number of subdivisions per side
  90904. * @param scene defines the hosting scene
  90905. * @param updatable defines if the mesh must be flagged as updatable
  90906. * @returns a new Mesh
  90907. */
  90908. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  90909. /**
  90910. * Creates a tiled ground mesh.
  90911. * Please consider using the same method from the MeshBuilder class instead
  90912. * @param name defines the name of the mesh to create
  90913. * @param xmin set the ground minimum X coordinate
  90914. * @param zmin set the ground minimum Y coordinate
  90915. * @param xmax set the ground maximum X coordinate
  90916. * @param zmax set the ground maximum Z coordinate
  90917. * @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
  90918. * @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
  90919. * @param scene defines the hosting scene
  90920. * @param updatable defines if the mesh must be flagged as updatable
  90921. * @returns a new Mesh
  90922. */
  90923. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  90924. w: number;
  90925. h: number;
  90926. }, precision: {
  90927. w: number;
  90928. h: number;
  90929. }, scene: Scene, updatable?: boolean): Mesh;
  90930. /**
  90931. * Creates a ground mesh from a height map.
  90932. * Please consider using the same method from the MeshBuilder class instead
  90933. * @see http://doc.babylonjs.com/babylon101/height_map
  90934. * @param name defines the name of the mesh to create
  90935. * @param url sets the URL of the height map image resource
  90936. * @param width set the ground width size
  90937. * @param height set the ground height size
  90938. * @param subdivisions sets the number of subdivision per side
  90939. * @param minHeight is the minimum altitude on the ground
  90940. * @param maxHeight is the maximum altitude on the ground
  90941. * @param scene defines the hosting scene
  90942. * @param updatable defines if the mesh must be flagged as updatable
  90943. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  90944. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  90945. * @returns a new Mesh
  90946. */
  90947. 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;
  90948. /**
  90949. * Creates a tube mesh.
  90950. * The tube is a parametric shape.
  90951. * It has no predefined shape. Its final shape will depend on the input parameters.
  90952. * Please consider using the same method from the MeshBuilder class instead
  90953. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90954. * @param name defines the name of the mesh to create
  90955. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  90956. * @param radius sets the tube radius size
  90957. * @param tessellation is the number of sides on the tubular surface
  90958. * @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
  90959. * @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
  90960. * @param scene defines the hosting scene
  90961. * @param updatable defines if the mesh must be flagged as updatable
  90962. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90963. * @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)
  90964. * @returns a new Mesh
  90965. */
  90966. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  90967. (i: number, distance: number): number;
  90968. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90969. /**
  90970. * Creates a polyhedron mesh.
  90971. * Please consider using the same method from the MeshBuilder class instead.
  90972. * * 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
  90973. * * The parameter `size` (positive float, default 1) sets the polygon size
  90974. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  90975. * * 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`
  90976. * * 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
  90977. * * 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)`)
  90978. * * 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
  90979. * * 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
  90980. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90981. * * If you create a double-sided mesh, you can choose what parts of 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
  90982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90983. * @param name defines the name of the mesh to create
  90984. * @param options defines the options used to create the mesh
  90985. * @param scene defines the hosting scene
  90986. * @returns a new Mesh
  90987. */
  90988. static CreatePolyhedron(name: string, options: {
  90989. type?: number;
  90990. size?: number;
  90991. sizeX?: number;
  90992. sizeY?: number;
  90993. sizeZ?: number;
  90994. custom?: any;
  90995. faceUV?: Vector4[];
  90996. faceColors?: Color4[];
  90997. updatable?: boolean;
  90998. sideOrientation?: number;
  90999. }, scene: Scene): Mesh;
  91000. /**
  91001. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  91002. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  91003. * * 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`)
  91004. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  91005. * * 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
  91006. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91007. * * If you create a double-sided mesh, you can choose what parts of 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
  91008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91009. * @param name defines the name of the mesh
  91010. * @param options defines the options used to create the mesh
  91011. * @param scene defines the hosting scene
  91012. * @returns a new Mesh
  91013. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  91014. */
  91015. static CreateIcoSphere(name: string, options: {
  91016. radius?: number;
  91017. flat?: boolean;
  91018. subdivisions?: number;
  91019. sideOrientation?: number;
  91020. updatable?: boolean;
  91021. }, scene: Scene): Mesh;
  91022. /**
  91023. * Creates a decal mesh.
  91024. * Please consider using the same method from the MeshBuilder class instead.
  91025. * A decal is a mesh usually applied as a model onto the surface of another mesh
  91026. * @param name defines the name of the mesh
  91027. * @param sourceMesh defines the mesh receiving the decal
  91028. * @param position sets the position of the decal in world coordinates
  91029. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  91030. * @param size sets the decal scaling
  91031. * @param angle sets the angle to rotate the decal
  91032. * @returns a new Mesh
  91033. */
  91034. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  91035. /**
  91036. * Prepare internal position array for software CPU skinning
  91037. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  91038. */
  91039. setPositionsForCPUSkinning(): Float32Array;
  91040. /**
  91041. * Prepare internal normal array for software CPU skinning
  91042. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  91043. */
  91044. setNormalsForCPUSkinning(): Float32Array;
  91045. /**
  91046. * Updates the vertex buffer by applying transformation from the bones
  91047. * @param skeleton defines the skeleton to apply to current mesh
  91048. * @returns the current mesh
  91049. */
  91050. applySkeleton(skeleton: Skeleton): Mesh;
  91051. /**
  91052. * 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
  91053. * @param meshes defines the list of meshes to scan
  91054. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  91055. */
  91056. static MinMax(meshes: AbstractMesh[]): {
  91057. min: Vector3;
  91058. max: Vector3;
  91059. };
  91060. /**
  91061. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  91062. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  91063. * @returns a vector3
  91064. */
  91065. static Center(meshesOrMinMaxVector: {
  91066. min: Vector3;
  91067. max: Vector3;
  91068. } | AbstractMesh[]): Vector3;
  91069. /**
  91070. * Merge the array of meshes into a single mesh for performance reasons.
  91071. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  91072. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  91073. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  91074. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  91075. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  91076. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  91077. * @returns a new mesh
  91078. */
  91079. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  91080. /** @hidden */
  91081. addInstance(instance: InstancedMesh): void;
  91082. /** @hidden */
  91083. removeInstance(instance: InstancedMesh): void;
  91084. }
  91085. }
  91086. declare module BABYLON {
  91087. /**
  91088. * This is the base class of all the camera used in the application.
  91089. * @see http://doc.babylonjs.com/features/cameras
  91090. */
  91091. export class Camera extends Node {
  91092. /** @hidden */
  91093. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  91094. /**
  91095. * This is the default projection mode used by the cameras.
  91096. * It helps recreating a feeling of perspective and better appreciate depth.
  91097. * This is the best way to simulate real life cameras.
  91098. */
  91099. static readonly PERSPECTIVE_CAMERA: number;
  91100. /**
  91101. * This helps creating camera with an orthographic mode.
  91102. * 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.
  91103. */
  91104. static readonly ORTHOGRAPHIC_CAMERA: number;
  91105. /**
  91106. * This is the default FOV mode for perspective cameras.
  91107. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  91108. */
  91109. static readonly FOVMODE_VERTICAL_FIXED: number;
  91110. /**
  91111. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  91112. */
  91113. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  91114. /**
  91115. * This specifies ther is no need for a camera rig.
  91116. * Basically only one eye is rendered corresponding to the camera.
  91117. */
  91118. static readonly RIG_MODE_NONE: number;
  91119. /**
  91120. * Simulates a camera Rig with one blue eye and one red eye.
  91121. * This can be use with 3d blue and red glasses.
  91122. */
  91123. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  91124. /**
  91125. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  91126. */
  91127. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  91128. /**
  91129. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  91130. */
  91131. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  91132. /**
  91133. * Defines that both eyes of the camera will be rendered over under each other.
  91134. */
  91135. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  91136. /**
  91137. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  91138. */
  91139. static readonly RIG_MODE_VR: number;
  91140. /**
  91141. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  91142. */
  91143. static readonly RIG_MODE_WEBVR: number;
  91144. /**
  91145. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  91146. */
  91147. static readonly RIG_MODE_CUSTOM: number;
  91148. /**
  91149. * Defines if by default attaching controls should prevent the default javascript event to continue.
  91150. */
  91151. static ForceAttachControlToAlwaysPreventDefault: boolean;
  91152. /**
  91153. * Define the input manager associated with the camera.
  91154. */
  91155. inputs: CameraInputsManager<Camera>;
  91156. /** @hidden */
  91157. _position: Vector3;
  91158. /**
  91159. * Define the current local position of the camera in the scene
  91160. */
  91161. position: Vector3;
  91162. /**
  91163. * The vector the camera should consider as up.
  91164. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  91165. */
  91166. upVector: Vector3;
  91167. /**
  91168. * Define the current limit on the left side for an orthographic camera
  91169. * In scene unit
  91170. */
  91171. orthoLeft: Nullable<number>;
  91172. /**
  91173. * Define the current limit on the right side for an orthographic camera
  91174. * In scene unit
  91175. */
  91176. orthoRight: Nullable<number>;
  91177. /**
  91178. * Define the current limit on the bottom side for an orthographic camera
  91179. * In scene unit
  91180. */
  91181. orthoBottom: Nullable<number>;
  91182. /**
  91183. * Define the current limit on the top side for an orthographic camera
  91184. * In scene unit
  91185. */
  91186. orthoTop: Nullable<number>;
  91187. /**
  91188. * Field Of View is set in Radians. (default is 0.8)
  91189. */
  91190. fov: number;
  91191. /**
  91192. * Define the minimum distance the camera can see from.
  91193. * This is important to note that the depth buffer are not infinite and the closer it starts
  91194. * the more your scene might encounter depth fighting issue.
  91195. */
  91196. minZ: number;
  91197. /**
  91198. * Define the maximum distance the camera can see to.
  91199. * This is important to note that the depth buffer are not infinite and the further it end
  91200. * the more your scene might encounter depth fighting issue.
  91201. */
  91202. maxZ: number;
  91203. /**
  91204. * Define the default inertia of the camera.
  91205. * This helps giving a smooth feeling to the camera movement.
  91206. */
  91207. inertia: number;
  91208. /**
  91209. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  91210. */
  91211. mode: number;
  91212. /**
  91213. * Define wether the camera is intermediate.
  91214. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  91215. */
  91216. isIntermediate: boolean;
  91217. /**
  91218. * Define the viewport of the camera.
  91219. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  91220. */
  91221. viewport: Viewport;
  91222. /**
  91223. * Restricts the camera to viewing objects with the same layerMask.
  91224. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  91225. */
  91226. layerMask: number;
  91227. /**
  91228. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  91229. */
  91230. fovMode: number;
  91231. /**
  91232. * Rig mode of the camera.
  91233. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  91234. * This is normally controlled byt the camera themselves as internal use.
  91235. */
  91236. cameraRigMode: number;
  91237. /**
  91238. * Defines the distance between both "eyes" in case of a RIG
  91239. */
  91240. interaxialDistance: number;
  91241. /**
  91242. * Defines if stereoscopic rendering is done side by side or over under.
  91243. */
  91244. isStereoscopicSideBySide: boolean;
  91245. /**
  91246. * 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
  91247. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  91248. * else in the scene. (Eg. security camera)
  91249. *
  91250. * 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)
  91251. */
  91252. customRenderTargets: RenderTargetTexture[];
  91253. /**
  91254. * When set, the camera will render to this render target instead of the default canvas
  91255. *
  91256. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  91257. */
  91258. outputRenderTarget: Nullable<RenderTargetTexture>;
  91259. /**
  91260. * Observable triggered when the camera view matrix has changed.
  91261. */
  91262. onViewMatrixChangedObservable: Observable<Camera>;
  91263. /**
  91264. * Observable triggered when the camera Projection matrix has changed.
  91265. */
  91266. onProjectionMatrixChangedObservable: Observable<Camera>;
  91267. /**
  91268. * Observable triggered when the inputs have been processed.
  91269. */
  91270. onAfterCheckInputsObservable: Observable<Camera>;
  91271. /**
  91272. * Observable triggered when reset has been called and applied to the camera.
  91273. */
  91274. onRestoreStateObservable: Observable<Camera>;
  91275. /** @hidden */
  91276. _cameraRigParams: any;
  91277. /** @hidden */
  91278. _rigCameras: Camera[];
  91279. /** @hidden */
  91280. _rigPostProcess: Nullable<PostProcess>;
  91281. protected _webvrViewMatrix: Matrix;
  91282. /** @hidden */
  91283. _skipRendering: boolean;
  91284. /** @hidden */
  91285. _projectionMatrix: Matrix;
  91286. /** @hidden */
  91287. _postProcesses: Nullable<PostProcess>[];
  91288. /** @hidden */
  91289. _activeMeshes: SmartArray<AbstractMesh>;
  91290. protected _globalPosition: Vector3;
  91291. /** @hidden */
  91292. _computedViewMatrix: Matrix;
  91293. private _doNotComputeProjectionMatrix;
  91294. private _transformMatrix;
  91295. private _frustumPlanes;
  91296. private _refreshFrustumPlanes;
  91297. private _storedFov;
  91298. private _stateStored;
  91299. /**
  91300. * Instantiates a new camera object.
  91301. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  91302. * @see http://doc.babylonjs.com/features/cameras
  91303. * @param name Defines the name of the camera in the scene
  91304. * @param position Defines the position of the camera
  91305. * @param scene Defines the scene the camera belongs too
  91306. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  91307. */
  91308. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91309. /**
  91310. * Store current camera state (fov, position, etc..)
  91311. * @returns the camera
  91312. */
  91313. storeState(): Camera;
  91314. /**
  91315. * Restores the camera state values if it has been stored. You must call storeState() first
  91316. */
  91317. protected _restoreStateValues(): boolean;
  91318. /**
  91319. * Restored camera state. You must call storeState() first.
  91320. * @returns true if restored and false otherwise
  91321. */
  91322. restoreState(): boolean;
  91323. /**
  91324. * Gets the class name of the camera.
  91325. * @returns the class name
  91326. */
  91327. getClassName(): string;
  91328. /** @hidden */
  91329. readonly _isCamera: boolean;
  91330. /**
  91331. * Gets a string representation of the camera useful for debug purpose.
  91332. * @param fullDetails Defines that a more verboe level of logging is required
  91333. * @returns the string representation
  91334. */
  91335. toString(fullDetails?: boolean): string;
  91336. /**
  91337. * Gets the current world space position of the camera.
  91338. */
  91339. readonly globalPosition: Vector3;
  91340. /**
  91341. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  91342. * @returns the active meshe list
  91343. */
  91344. getActiveMeshes(): SmartArray<AbstractMesh>;
  91345. /**
  91346. * Check wether a mesh is part of the current active mesh list of the camera
  91347. * @param mesh Defines the mesh to check
  91348. * @returns true if active, false otherwise
  91349. */
  91350. isActiveMesh(mesh: Mesh): boolean;
  91351. /**
  91352. * Is this camera ready to be used/rendered
  91353. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  91354. * @return true if the camera is ready
  91355. */
  91356. isReady(completeCheck?: boolean): boolean;
  91357. /** @hidden */
  91358. _initCache(): void;
  91359. /** @hidden */
  91360. _updateCache(ignoreParentClass?: boolean): void;
  91361. /** @hidden */
  91362. _isSynchronized(): boolean;
  91363. /** @hidden */
  91364. _isSynchronizedViewMatrix(): boolean;
  91365. /** @hidden */
  91366. _isSynchronizedProjectionMatrix(): boolean;
  91367. /**
  91368. * Attach the input controls to a specific dom element to get the input from.
  91369. * @param element Defines the element the controls should be listened from
  91370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91371. */
  91372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91373. /**
  91374. * Detach the current controls from the specified dom element.
  91375. * @param element Defines the element to stop listening the inputs from
  91376. */
  91377. detachControl(element: HTMLElement): void;
  91378. /**
  91379. * Update the camera state according to the different inputs gathered during the frame.
  91380. */
  91381. update(): void;
  91382. /** @hidden */
  91383. _checkInputs(): void;
  91384. /** @hidden */
  91385. readonly rigCameras: Camera[];
  91386. /**
  91387. * Gets the post process used by the rig cameras
  91388. */
  91389. readonly rigPostProcess: Nullable<PostProcess>;
  91390. /**
  91391. * Internal, gets the first post proces.
  91392. * @returns the first post process to be run on this camera.
  91393. */
  91394. _getFirstPostProcess(): Nullable<PostProcess>;
  91395. private _cascadePostProcessesToRigCams;
  91396. /**
  91397. * Attach a post process to the camera.
  91398. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91399. * @param postProcess The post process to attach to the camera
  91400. * @param insertAt The position of the post process in case several of them are in use in the scene
  91401. * @returns the position the post process has been inserted at
  91402. */
  91403. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  91404. /**
  91405. * Detach a post process to the camera.
  91406. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91407. * @param postProcess The post process to detach from the camera
  91408. */
  91409. detachPostProcess(postProcess: PostProcess): void;
  91410. /**
  91411. * Gets the current world matrix of the camera
  91412. */
  91413. getWorldMatrix(): Matrix;
  91414. /** @hidden */
  91415. _getViewMatrix(): Matrix;
  91416. /**
  91417. * Gets the current view matrix of the camera.
  91418. * @param force forces the camera to recompute the matrix without looking at the cached state
  91419. * @returns the view matrix
  91420. */
  91421. getViewMatrix(force?: boolean): Matrix;
  91422. /**
  91423. * Freeze the projection matrix.
  91424. * It will prevent the cache check of the camera projection compute and can speed up perf
  91425. * if no parameter of the camera are meant to change
  91426. * @param projection Defines manually a projection if necessary
  91427. */
  91428. freezeProjectionMatrix(projection?: Matrix): void;
  91429. /**
  91430. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  91431. */
  91432. unfreezeProjectionMatrix(): void;
  91433. /**
  91434. * Gets the current projection matrix of the camera.
  91435. * @param force forces the camera to recompute the matrix without looking at the cached state
  91436. * @returns the projection matrix
  91437. */
  91438. getProjectionMatrix(force?: boolean): Matrix;
  91439. /**
  91440. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  91441. * @returns a Matrix
  91442. */
  91443. getTransformationMatrix(): Matrix;
  91444. private _updateFrustumPlanes;
  91445. /**
  91446. * Checks if a cullable object (mesh...) is in the camera frustum
  91447. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  91448. * @param target The object to check
  91449. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  91450. * @returns true if the object is in frustum otherwise false
  91451. */
  91452. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  91453. /**
  91454. * Checks if a cullable object (mesh...) is in the camera frustum
  91455. * Unlike isInFrustum this cheks the full bounding box
  91456. * @param target The object to check
  91457. * @returns true if the object is in frustum otherwise false
  91458. */
  91459. isCompletelyInFrustum(target: ICullable): boolean;
  91460. /**
  91461. * Gets a ray in the forward direction from the camera.
  91462. * @param length Defines the length of the ray to create
  91463. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  91464. * @param origin Defines the start point of the ray which defaults to the camera position
  91465. * @returns the forward ray
  91466. */
  91467. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  91468. /**
  91469. * Releases resources associated with this node.
  91470. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91471. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91472. */
  91473. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91474. /** @hidden */
  91475. _isLeftCamera: boolean;
  91476. /**
  91477. * Gets the left camera of a rig setup in case of Rigged Camera
  91478. */
  91479. readonly isLeftCamera: boolean;
  91480. /** @hidden */
  91481. _isRightCamera: boolean;
  91482. /**
  91483. * Gets the right camera of a rig setup in case of Rigged Camera
  91484. */
  91485. readonly isRightCamera: boolean;
  91486. /**
  91487. * Gets the left camera of a rig setup in case of Rigged Camera
  91488. */
  91489. readonly leftCamera: Nullable<FreeCamera>;
  91490. /**
  91491. * Gets the right camera of a rig setup in case of Rigged Camera
  91492. */
  91493. readonly rightCamera: Nullable<FreeCamera>;
  91494. /**
  91495. * Gets the left camera target of a rig setup in case of Rigged Camera
  91496. * @returns the target position
  91497. */
  91498. getLeftTarget(): Nullable<Vector3>;
  91499. /**
  91500. * Gets the right camera target of a rig setup in case of Rigged Camera
  91501. * @returns the target position
  91502. */
  91503. getRightTarget(): Nullable<Vector3>;
  91504. /**
  91505. * @hidden
  91506. */
  91507. setCameraRigMode(mode: number, rigParams: any): void;
  91508. /** @hidden */
  91509. static _setStereoscopicRigMode(camera: Camera): void;
  91510. /** @hidden */
  91511. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  91512. /** @hidden */
  91513. static _setVRRigMode(camera: Camera, rigParams: any): void;
  91514. /** @hidden */
  91515. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  91516. /** @hidden */
  91517. _getVRProjectionMatrix(): Matrix;
  91518. protected _updateCameraRotationMatrix(): void;
  91519. protected _updateWebVRCameraRotationMatrix(): void;
  91520. /**
  91521. * This function MUST be overwritten by the different WebVR cameras available.
  91522. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91523. * @hidden
  91524. */
  91525. _getWebVRProjectionMatrix(): Matrix;
  91526. /**
  91527. * This function MUST be overwritten by the different WebVR cameras available.
  91528. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91529. * @hidden
  91530. */
  91531. _getWebVRViewMatrix(): Matrix;
  91532. /** @hidden */
  91533. setCameraRigParameter(name: string, value: any): void;
  91534. /**
  91535. * needs to be overridden by children so sub has required properties to be copied
  91536. * @hidden
  91537. */
  91538. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  91539. /**
  91540. * May need to be overridden by children
  91541. * @hidden
  91542. */
  91543. _updateRigCameras(): void;
  91544. /** @hidden */
  91545. _setupInputs(): void;
  91546. /**
  91547. * Serialiaze the camera setup to a json represention
  91548. * @returns the JSON representation
  91549. */
  91550. serialize(): any;
  91551. /**
  91552. * Clones the current camera.
  91553. * @param name The cloned camera name
  91554. * @returns the cloned camera
  91555. */
  91556. clone(name: string): Camera;
  91557. /**
  91558. * Gets the direction of the camera relative to a given local axis.
  91559. * @param localAxis Defines the reference axis to provide a relative direction.
  91560. * @return the direction
  91561. */
  91562. getDirection(localAxis: Vector3): Vector3;
  91563. /**
  91564. * Returns the current camera absolute rotation
  91565. */
  91566. readonly absoluteRotation: Quaternion;
  91567. /**
  91568. * Gets the direction of the camera relative to a given local axis into a passed vector.
  91569. * @param localAxis Defines the reference axis to provide a relative direction.
  91570. * @param result Defines the vector to store the result in
  91571. */
  91572. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  91573. /**
  91574. * Gets a camera constructor for a given camera type
  91575. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  91576. * @param name The name of the camera the result will be able to instantiate
  91577. * @param scene The scene the result will construct the camera in
  91578. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  91579. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  91580. * @returns a factory method to construc the camera
  91581. */
  91582. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  91583. /**
  91584. * Compute the world matrix of the camera.
  91585. * @returns the camera workd matrix
  91586. */
  91587. computeWorldMatrix(): Matrix;
  91588. /**
  91589. * Parse a JSON and creates the camera from the parsed information
  91590. * @param parsedCamera The JSON to parse
  91591. * @param scene The scene to instantiate the camera in
  91592. * @returns the newly constructed camera
  91593. */
  91594. static Parse(parsedCamera: any, scene: Scene): Camera;
  91595. }
  91596. }
  91597. declare module BABYLON {
  91598. /**
  91599. * Class containing static functions to help procedurally build meshes
  91600. */
  91601. export class DiscBuilder {
  91602. /**
  91603. * Creates a plane polygonal mesh. By default, this is a disc
  91604. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  91605. * * 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
  91606. * * 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
  91607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91608. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  91609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91610. * @param name defines the name of the mesh
  91611. * @param options defines the options used to create the mesh
  91612. * @param scene defines the hosting scene
  91613. * @returns the plane polygonal mesh
  91614. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  91615. */
  91616. static CreateDisc(name: string, options: {
  91617. radius?: number;
  91618. tessellation?: number;
  91619. arc?: number;
  91620. updatable?: boolean;
  91621. sideOrientation?: number;
  91622. frontUVs?: Vector4;
  91623. backUVs?: Vector4;
  91624. }, scene?: Nullable<Scene>): Mesh;
  91625. }
  91626. }
  91627. declare module BABYLON {
  91628. /**
  91629. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  91630. *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.
  91631. * The SPS is also a particle system. It provides some methods to manage the particles.
  91632. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  91633. *
  91634. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  91635. */
  91636. export class SolidParticleSystem implements IDisposable {
  91637. /**
  91638. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  91639. * Example : var p = SPS.particles[i];
  91640. */
  91641. particles: SolidParticle[];
  91642. /**
  91643. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  91644. */
  91645. nbParticles: number;
  91646. /**
  91647. * If the particles must ever face the camera (default false). Useful for planar particles.
  91648. */
  91649. billboard: boolean;
  91650. /**
  91651. * Recompute normals when adding a shape
  91652. */
  91653. recomputeNormals: boolean;
  91654. /**
  91655. * This a counter ofr your own usage. It's not set by any SPS functions.
  91656. */
  91657. counter: number;
  91658. /**
  91659. * The SPS name. This name is also given to the underlying mesh.
  91660. */
  91661. name: string;
  91662. /**
  91663. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  91664. */
  91665. mesh: Mesh;
  91666. /**
  91667. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  91668. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  91669. */
  91670. vars: any;
  91671. /**
  91672. * This array is populated when the SPS is set as 'pickable'.
  91673. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  91674. * Each element of this array is an object `{idx: int, faceId: int}`.
  91675. * `idx` is the picked particle index in the `SPS.particles` array
  91676. * `faceId` is the picked face index counted within this particle.
  91677. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  91678. */
  91679. pickedParticles: {
  91680. idx: number;
  91681. faceId: number;
  91682. }[];
  91683. /**
  91684. * This array is populated when `enableDepthSort` is set to true.
  91685. * Each element of this array is an instance of the class DepthSortedParticle.
  91686. */
  91687. depthSortedParticles: DepthSortedParticle[];
  91688. /**
  91689. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  91690. * @hidden
  91691. */
  91692. _bSphereOnly: boolean;
  91693. /**
  91694. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  91695. * @hidden
  91696. */
  91697. _bSphereRadiusFactor: number;
  91698. private _scene;
  91699. private _positions;
  91700. private _indices;
  91701. private _normals;
  91702. private _colors;
  91703. private _uvs;
  91704. private _indices32;
  91705. private _positions32;
  91706. private _normals32;
  91707. private _fixedNormal32;
  91708. private _colors32;
  91709. private _uvs32;
  91710. private _index;
  91711. private _updatable;
  91712. private _pickable;
  91713. private _isVisibilityBoxLocked;
  91714. private _alwaysVisible;
  91715. private _depthSort;
  91716. private _shapeCounter;
  91717. private _copy;
  91718. private _color;
  91719. private _computeParticleColor;
  91720. private _computeParticleTexture;
  91721. private _computeParticleRotation;
  91722. private _computeParticleVertex;
  91723. private _computeBoundingBox;
  91724. private _depthSortParticles;
  91725. private _camera;
  91726. private _mustUnrotateFixedNormals;
  91727. private _particlesIntersect;
  91728. private _needs32Bits;
  91729. /**
  91730. * Creates a SPS (Solid Particle System) object.
  91731. * @param name (String) is the SPS name, this will be the underlying mesh name.
  91732. * @param scene (Scene) is the scene in which the SPS is added.
  91733. * @param options defines the options of the sps e.g.
  91734. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  91735. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  91736. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  91737. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  91738. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  91739. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  91740. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  91741. */
  91742. constructor(name: string, scene: Scene, options?: {
  91743. updatable?: boolean;
  91744. isPickable?: boolean;
  91745. enableDepthSort?: boolean;
  91746. particleIntersection?: boolean;
  91747. boundingSphereOnly?: boolean;
  91748. bSphereRadiusFactor?: number;
  91749. });
  91750. /**
  91751. * Builds the SPS underlying mesh. Returns a standard Mesh.
  91752. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  91753. * @returns the created mesh
  91754. */
  91755. buildMesh(): Mesh;
  91756. /**
  91757. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  91758. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  91759. * Thus the particles generated from `digest()` have their property `position` set yet.
  91760. * @param mesh ( Mesh ) is the mesh to be digested
  91761. * @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
  91762. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  91763. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  91764. * @returns the current SPS
  91765. */
  91766. digest(mesh: Mesh, options?: {
  91767. facetNb?: number;
  91768. number?: number;
  91769. delta?: number;
  91770. }): SolidParticleSystem;
  91771. private _unrotateFixedNormals;
  91772. private _resetCopy;
  91773. private _meshBuilder;
  91774. private _posToShape;
  91775. private _uvsToShapeUV;
  91776. private _addParticle;
  91777. /**
  91778. * Adds some particles to the SPS from the model shape. Returns the shape id.
  91779. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  91780. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  91781. * @param nb (positive integer) the number of particles to be created from this model
  91782. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  91783. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  91784. * @returns the number of shapes in the system
  91785. */
  91786. addShape(mesh: Mesh, nb: number, options?: {
  91787. positionFunction?: any;
  91788. vertexFunction?: any;
  91789. }): number;
  91790. private _rebuildParticle;
  91791. /**
  91792. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  91793. * @returns the SPS.
  91794. */
  91795. rebuildMesh(): SolidParticleSystem;
  91796. /**
  91797. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  91798. * This method calls `updateParticle()` for each particle of the SPS.
  91799. * For an animated SPS, it is usually called within the render loop.
  91800. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  91801. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  91802. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  91803. * @returns the SPS.
  91804. */
  91805. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  91806. /**
  91807. * Disposes the SPS.
  91808. */
  91809. dispose(): void;
  91810. /**
  91811. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  91812. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91813. * @returns the SPS.
  91814. */
  91815. refreshVisibleSize(): SolidParticleSystem;
  91816. /**
  91817. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  91818. * @param size the size (float) of the visibility box
  91819. * note : this doesn't lock the SPS mesh bounding box.
  91820. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91821. */
  91822. setVisibilityBox(size: number): void;
  91823. /**
  91824. * Gets whether the SPS as always visible or not
  91825. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91826. */
  91827. /**
  91828. * Sets the SPS as always visible or not
  91829. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91830. */
  91831. isAlwaysVisible: boolean;
  91832. /**
  91833. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  91834. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91835. */
  91836. /**
  91837. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  91838. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91839. */
  91840. isVisibilityBoxLocked: boolean;
  91841. /**
  91842. * Tells to `setParticles()` to compute the particle rotations or not.
  91843. * Default value : true. The SPS is faster when it's set to false.
  91844. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91845. */
  91846. /**
  91847. * Gets if `setParticles()` computes the particle rotations or not.
  91848. * Default value : true. The SPS is faster when it's set to false.
  91849. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91850. */
  91851. computeParticleRotation: boolean;
  91852. /**
  91853. * Tells to `setParticles()` to compute the particle colors or not.
  91854. * Default value : true. The SPS is faster when it's set to false.
  91855. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91856. */
  91857. /**
  91858. * Gets if `setParticles()` computes the particle colors or not.
  91859. * Default value : true. The SPS is faster when it's set to false.
  91860. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91861. */
  91862. computeParticleColor: boolean;
  91863. /**
  91864. * Gets if `setParticles()` computes the particle textures or not.
  91865. * Default value : true. The SPS is faster when it's set to false.
  91866. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  91867. */
  91868. computeParticleTexture: boolean;
  91869. /**
  91870. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  91871. * Default value : false. The SPS is faster when it's set to false.
  91872. * Note : the particle custom vertex positions aren't stored values.
  91873. */
  91874. /**
  91875. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  91876. * Default value : false. The SPS is faster when it's set to false.
  91877. * Note : the particle custom vertex positions aren't stored values.
  91878. */
  91879. computeParticleVertex: boolean;
  91880. /**
  91881. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  91882. */
  91883. /**
  91884. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  91885. */
  91886. computeBoundingBox: boolean;
  91887. /**
  91888. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  91889. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91890. * Default : `true`
  91891. */
  91892. /**
  91893. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  91894. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91895. * Default : `true`
  91896. */
  91897. depthSortParticles: boolean;
  91898. /**
  91899. * This function does nothing. It may be overwritten to set all the particle first values.
  91900. * The SPS doesn't call this function, you may have to call it by your own.
  91901. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91902. */
  91903. initParticles(): void;
  91904. /**
  91905. * This function does nothing. It may be overwritten to recycle a particle.
  91906. * The SPS doesn't call this function, you may have to call it by your own.
  91907. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91908. * @param particle The particle to recycle
  91909. * @returns the recycled particle
  91910. */
  91911. recycleParticle(particle: SolidParticle): SolidParticle;
  91912. /**
  91913. * Updates a particle : this function should be overwritten by the user.
  91914. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  91915. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91916. * @example : just set a particle position or velocity and recycle conditions
  91917. * @param particle The particle to update
  91918. * @returns the updated particle
  91919. */
  91920. updateParticle(particle: SolidParticle): SolidParticle;
  91921. /**
  91922. * Updates a vertex of a particle : it can be overwritten by the user.
  91923. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  91924. * @param particle the current particle
  91925. * @param vertex the current index of the current particle
  91926. * @param pt the index of the current vertex in the particle shape
  91927. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  91928. * @example : just set a vertex particle position
  91929. * @returns the updated vertex
  91930. */
  91931. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  91932. /**
  91933. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  91934. * This does nothing and may be overwritten by the user.
  91935. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91936. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91937. * @param update the boolean update value actually passed to setParticles()
  91938. */
  91939. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91940. /**
  91941. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  91942. * This will be passed three parameters.
  91943. * This does nothing and may be overwritten by the user.
  91944. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91945. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91946. * @param update the boolean update value actually passed to setParticles()
  91947. */
  91948. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91949. }
  91950. }
  91951. declare module BABYLON {
  91952. /**
  91953. * Represents one particle of a solid particle system.
  91954. */
  91955. export class SolidParticle {
  91956. /**
  91957. * particle global index
  91958. */
  91959. idx: number;
  91960. /**
  91961. * The color of the particle
  91962. */
  91963. color: Nullable<Color4>;
  91964. /**
  91965. * The world space position of the particle.
  91966. */
  91967. position: Vector3;
  91968. /**
  91969. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  91970. */
  91971. rotation: Vector3;
  91972. /**
  91973. * The world space rotation quaternion of the particle.
  91974. */
  91975. rotationQuaternion: Nullable<Quaternion>;
  91976. /**
  91977. * The scaling of the particle.
  91978. */
  91979. scaling: Vector3;
  91980. /**
  91981. * The uvs of the particle.
  91982. */
  91983. uvs: Vector4;
  91984. /**
  91985. * The current speed of the particle.
  91986. */
  91987. velocity: Vector3;
  91988. /**
  91989. * The pivot point in the particle local space.
  91990. */
  91991. pivot: Vector3;
  91992. /**
  91993. * Must the particle be translated from its pivot point in its local space ?
  91994. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  91995. * Default : false
  91996. */
  91997. translateFromPivot: boolean;
  91998. /**
  91999. * Is the particle active or not ?
  92000. */
  92001. alive: boolean;
  92002. /**
  92003. * Is the particle visible or not ?
  92004. */
  92005. isVisible: boolean;
  92006. /**
  92007. * Index of this particle in the global "positions" array (Internal use)
  92008. * @hidden
  92009. */
  92010. _pos: number;
  92011. /**
  92012. * @hidden Index of this particle in the global "indices" array (Internal use)
  92013. */
  92014. _ind: number;
  92015. /**
  92016. * @hidden ModelShape of this particle (Internal use)
  92017. */
  92018. _model: ModelShape;
  92019. /**
  92020. * ModelShape id of this particle
  92021. */
  92022. shapeId: number;
  92023. /**
  92024. * Index of the particle in its shape id
  92025. */
  92026. idxInShape: number;
  92027. /**
  92028. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  92029. */
  92030. _modelBoundingInfo: BoundingInfo;
  92031. /**
  92032. * @hidden Particle BoundingInfo object (Internal use)
  92033. */
  92034. _boundingInfo: BoundingInfo;
  92035. /**
  92036. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  92037. */
  92038. _sps: SolidParticleSystem;
  92039. /**
  92040. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  92041. */
  92042. _stillInvisible: boolean;
  92043. /**
  92044. * @hidden Last computed particle rotation matrix
  92045. */
  92046. _rotationMatrix: number[];
  92047. /**
  92048. * Parent particle Id, if any.
  92049. * Default null.
  92050. */
  92051. parentId: Nullable<number>;
  92052. /**
  92053. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  92054. * The possible values are :
  92055. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92056. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92057. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92058. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92059. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92060. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  92061. * */
  92062. cullingStrategy: number;
  92063. /**
  92064. * @hidden Internal global position in the SPS.
  92065. */
  92066. _globalPosition: Vector3;
  92067. /**
  92068. * Creates a Solid Particle object.
  92069. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  92070. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  92071. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  92072. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  92073. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  92074. * @param shapeId (integer) is the model shape identifier in the SPS.
  92075. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  92076. * @param sps defines the sps it is associated to
  92077. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  92078. */
  92079. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  92080. /**
  92081. * Legacy support, changed scale to scaling
  92082. */
  92083. /**
  92084. * Legacy support, changed scale to scaling
  92085. */
  92086. scale: Vector3;
  92087. /**
  92088. * Legacy support, changed quaternion to rotationQuaternion
  92089. */
  92090. /**
  92091. * Legacy support, changed quaternion to rotationQuaternion
  92092. */
  92093. quaternion: Nullable<Quaternion>;
  92094. /**
  92095. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  92096. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  92097. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  92098. * @returns true if it intersects
  92099. */
  92100. intersectsMesh(target: Mesh | SolidParticle): boolean;
  92101. /**
  92102. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  92103. * A particle is in the frustum if its bounding box intersects the frustum
  92104. * @param frustumPlanes defines the frustum to test
  92105. * @returns true if the particle is in the frustum planes
  92106. */
  92107. isInFrustum(frustumPlanes: Plane[]): boolean;
  92108. /**
  92109. * get the rotation matrix of the particle
  92110. * @hidden
  92111. */
  92112. getRotationMatrix(m: Matrix): void;
  92113. }
  92114. /**
  92115. * Represents the shape of the model used by one particle of a solid particle system.
  92116. * SPS internal tool, don't use it manually.
  92117. */
  92118. export class ModelShape {
  92119. /**
  92120. * The shape id
  92121. * @hidden
  92122. */
  92123. shapeID: number;
  92124. /**
  92125. * flat array of model positions (internal use)
  92126. * @hidden
  92127. */
  92128. _shape: Vector3[];
  92129. /**
  92130. * flat array of model UVs (internal use)
  92131. * @hidden
  92132. */
  92133. _shapeUV: number[];
  92134. /**
  92135. * length of the shape in the model indices array (internal use)
  92136. * @hidden
  92137. */
  92138. _indicesLength: number;
  92139. /**
  92140. * Custom position function (internal use)
  92141. * @hidden
  92142. */
  92143. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  92144. /**
  92145. * Custom vertex function (internal use)
  92146. * @hidden
  92147. */
  92148. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  92149. /**
  92150. * 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.
  92151. * SPS internal tool, don't use it manually.
  92152. * @hidden
  92153. */
  92154. 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>);
  92155. }
  92156. /**
  92157. * Represents a Depth Sorted Particle in the solid particle system.
  92158. */
  92159. export class DepthSortedParticle {
  92160. /**
  92161. * Index of the particle in the "indices" array
  92162. */
  92163. ind: number;
  92164. /**
  92165. * Length of the particle shape in the "indices" array
  92166. */
  92167. indicesLength: number;
  92168. /**
  92169. * Squared distance from the particle to the camera
  92170. */
  92171. sqDistance: number;
  92172. }
  92173. }
  92174. declare module BABYLON {
  92175. /**
  92176. * @hidden
  92177. */
  92178. export class _MeshCollisionData {
  92179. _checkCollisions: boolean;
  92180. _collisionMask: number;
  92181. _collisionGroup: number;
  92182. _collider: Nullable<Collider>;
  92183. _oldPositionForCollisions: Vector3;
  92184. _diffPositionForCollisions: Vector3;
  92185. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  92186. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  92187. }
  92188. }
  92189. declare module BABYLON {
  92190. /** @hidden */
  92191. class _FacetDataStorage {
  92192. facetPositions: Vector3[];
  92193. facetNormals: Vector3[];
  92194. facetPartitioning: number[][];
  92195. facetNb: number;
  92196. partitioningSubdivisions: number;
  92197. partitioningBBoxRatio: number;
  92198. facetDataEnabled: boolean;
  92199. facetParameters: any;
  92200. bbSize: Vector3;
  92201. subDiv: {
  92202. max: number;
  92203. X: number;
  92204. Y: number;
  92205. Z: number;
  92206. };
  92207. facetDepthSort: boolean;
  92208. facetDepthSortEnabled: boolean;
  92209. depthSortedIndices: IndicesArray;
  92210. depthSortedFacets: {
  92211. ind: number;
  92212. sqDistance: number;
  92213. }[];
  92214. facetDepthSortFunction: (f1: {
  92215. ind: number;
  92216. sqDistance: number;
  92217. }, f2: {
  92218. ind: number;
  92219. sqDistance: number;
  92220. }) => number;
  92221. facetDepthSortFrom: Vector3;
  92222. facetDepthSortOrigin: Vector3;
  92223. invertedMatrix: Matrix;
  92224. }
  92225. /**
  92226. * @hidden
  92227. **/
  92228. class _InternalAbstractMeshDataInfo {
  92229. _hasVertexAlpha: boolean;
  92230. _useVertexColors: boolean;
  92231. _numBoneInfluencers: number;
  92232. _applyFog: boolean;
  92233. _receiveShadows: boolean;
  92234. _facetData: _FacetDataStorage;
  92235. _visibility: number;
  92236. _skeleton: Nullable<Skeleton>;
  92237. _layerMask: number;
  92238. _computeBonesUsingShaders: boolean;
  92239. _isActive: boolean;
  92240. _onlyForInstances: boolean;
  92241. _isActiveIntermediate: boolean;
  92242. _onlyForInstancesIntermediate: boolean;
  92243. }
  92244. /**
  92245. * Class used to store all common mesh properties
  92246. */
  92247. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  92248. /** No occlusion */
  92249. static OCCLUSION_TYPE_NONE: number;
  92250. /** Occlusion set to optimisitic */
  92251. static OCCLUSION_TYPE_OPTIMISTIC: number;
  92252. /** Occlusion set to strict */
  92253. static OCCLUSION_TYPE_STRICT: number;
  92254. /** Use an accurante occlusion algorithm */
  92255. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  92256. /** Use a conservative occlusion algorithm */
  92257. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  92258. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  92259. * Test order :
  92260. * Is the bounding sphere outside the frustum ?
  92261. * If not, are the bounding box vertices outside the frustum ?
  92262. * It not, then the cullable object is in the frustum.
  92263. */
  92264. static readonly CULLINGSTRATEGY_STANDARD: number;
  92265. /** Culling strategy : Bounding Sphere Only.
  92266. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  92267. * It's also less accurate than the standard because some not visible objects can still be selected.
  92268. * Test : is the bounding sphere outside the frustum ?
  92269. * If not, then the cullable object is in the frustum.
  92270. */
  92271. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  92272. /** Culling strategy : Optimistic Inclusion.
  92273. * This in an inclusion test first, then the standard exclusion test.
  92274. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  92275. * 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.
  92276. * Anyway, it's as accurate as the standard strategy.
  92277. * Test :
  92278. * Is the cullable object bounding sphere center in the frustum ?
  92279. * If not, apply the default culling strategy.
  92280. */
  92281. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  92282. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  92283. * This in an inclusion test first, then the bounding sphere only exclusion test.
  92284. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  92285. * 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.
  92286. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  92287. * Test :
  92288. * Is the cullable object bounding sphere center in the frustum ?
  92289. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  92290. */
  92291. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  92292. /**
  92293. * No billboard
  92294. */
  92295. static readonly BILLBOARDMODE_NONE: number;
  92296. /** Billboard on X axis */
  92297. static readonly BILLBOARDMODE_X: number;
  92298. /** Billboard on Y axis */
  92299. static readonly BILLBOARDMODE_Y: number;
  92300. /** Billboard on Z axis */
  92301. static readonly BILLBOARDMODE_Z: number;
  92302. /** Billboard on all axes */
  92303. static readonly BILLBOARDMODE_ALL: number;
  92304. /** Billboard on using position instead of orientation */
  92305. static readonly BILLBOARDMODE_USE_POSITION: number;
  92306. /** @hidden */
  92307. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  92308. /**
  92309. * The culling strategy to use to check whether the mesh must be rendered or not.
  92310. * This value can be changed at any time and will be used on the next render mesh selection.
  92311. * The possible values are :
  92312. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92313. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92314. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92315. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92316. * Please read each static variable documentation to get details about the culling process.
  92317. * */
  92318. cullingStrategy: number;
  92319. /**
  92320. * Gets the number of facets in the mesh
  92321. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92322. */
  92323. readonly facetNb: number;
  92324. /**
  92325. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  92326. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92327. */
  92328. partitioningSubdivisions: number;
  92329. /**
  92330. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  92331. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  92332. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92333. */
  92334. partitioningBBoxRatio: number;
  92335. /**
  92336. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  92337. * Works only for updatable meshes.
  92338. * Doesn't work with multi-materials
  92339. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92340. */
  92341. mustDepthSortFacets: boolean;
  92342. /**
  92343. * The location (Vector3) where the facet depth sort must be computed from.
  92344. * By default, the active camera position.
  92345. * Used only when facet depth sort is enabled
  92346. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92347. */
  92348. facetDepthSortFrom: Vector3;
  92349. /**
  92350. * gets a boolean indicating if facetData is enabled
  92351. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92352. */
  92353. readonly isFacetDataEnabled: boolean;
  92354. /** @hidden */
  92355. _updateNonUniformScalingState(value: boolean): boolean;
  92356. /**
  92357. * An event triggered when this mesh collides with another one
  92358. */
  92359. onCollideObservable: Observable<AbstractMesh>;
  92360. /** Set a function to call when this mesh collides with another one */
  92361. onCollide: () => void;
  92362. /**
  92363. * An event triggered when the collision's position changes
  92364. */
  92365. onCollisionPositionChangeObservable: Observable<Vector3>;
  92366. /** Set a function to call when the collision's position changes */
  92367. onCollisionPositionChange: () => void;
  92368. /**
  92369. * An event triggered when material is changed
  92370. */
  92371. onMaterialChangedObservable: Observable<AbstractMesh>;
  92372. /**
  92373. * Gets or sets the orientation for POV movement & rotation
  92374. */
  92375. definedFacingForward: boolean;
  92376. /** @hidden */
  92377. _occlusionQuery: Nullable<WebGLQuery>;
  92378. /** @hidden */
  92379. _renderingGroup: Nullable<RenderingGroup>;
  92380. /**
  92381. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92382. */
  92383. /**
  92384. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92385. */
  92386. visibility: number;
  92387. /** Gets or sets the alpha index used to sort transparent meshes
  92388. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  92389. */
  92390. alphaIndex: number;
  92391. /**
  92392. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  92393. */
  92394. isVisible: boolean;
  92395. /**
  92396. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  92397. */
  92398. isPickable: boolean;
  92399. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  92400. showSubMeshesBoundingBox: boolean;
  92401. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  92402. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  92403. */
  92404. isBlocker: boolean;
  92405. /**
  92406. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  92407. */
  92408. enablePointerMoveEvents: boolean;
  92409. /**
  92410. * Specifies the rendering group id for this mesh (0 by default)
  92411. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  92412. */
  92413. renderingGroupId: number;
  92414. private _material;
  92415. /** Gets or sets current material */
  92416. material: Nullable<Material>;
  92417. /**
  92418. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  92419. * @see http://doc.babylonjs.com/babylon101/shadows
  92420. */
  92421. receiveShadows: boolean;
  92422. /** Defines color to use when rendering outline */
  92423. outlineColor: Color3;
  92424. /** Define width to use when rendering outline */
  92425. outlineWidth: number;
  92426. /** Defines color to use when rendering overlay */
  92427. overlayColor: Color3;
  92428. /** Defines alpha to use when rendering overlay */
  92429. overlayAlpha: number;
  92430. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  92431. hasVertexAlpha: boolean;
  92432. /** 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) */
  92433. useVertexColors: boolean;
  92434. /**
  92435. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  92436. */
  92437. computeBonesUsingShaders: boolean;
  92438. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  92439. numBoneInfluencers: number;
  92440. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  92441. applyFog: boolean;
  92442. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  92443. useOctreeForRenderingSelection: boolean;
  92444. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  92445. useOctreeForPicking: boolean;
  92446. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  92447. useOctreeForCollisions: boolean;
  92448. /**
  92449. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  92450. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  92451. */
  92452. layerMask: number;
  92453. /**
  92454. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  92455. */
  92456. alwaysSelectAsActiveMesh: boolean;
  92457. /**
  92458. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  92459. */
  92460. doNotSyncBoundingInfo: boolean;
  92461. /**
  92462. * Gets or sets the current action manager
  92463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92464. */
  92465. actionManager: Nullable<AbstractActionManager>;
  92466. private _meshCollisionData;
  92467. /**
  92468. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  92469. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92470. */
  92471. ellipsoid: Vector3;
  92472. /**
  92473. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  92474. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92475. */
  92476. ellipsoidOffset: Vector3;
  92477. /**
  92478. * Gets or sets a collision mask used to mask collisions (default is -1).
  92479. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92480. */
  92481. collisionMask: number;
  92482. /**
  92483. * Gets or sets the current collision group mask (-1 by default).
  92484. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92485. */
  92486. collisionGroup: number;
  92487. /**
  92488. * Defines edge width used when edgesRenderer is enabled
  92489. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92490. */
  92491. edgesWidth: number;
  92492. /**
  92493. * Defines edge color used when edgesRenderer is enabled
  92494. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92495. */
  92496. edgesColor: Color4;
  92497. /** @hidden */
  92498. _edgesRenderer: Nullable<IEdgesRenderer>;
  92499. /** @hidden */
  92500. _masterMesh: Nullable<AbstractMesh>;
  92501. /** @hidden */
  92502. _boundingInfo: Nullable<BoundingInfo>;
  92503. /** @hidden */
  92504. _renderId: number;
  92505. /**
  92506. * Gets or sets the list of subMeshes
  92507. * @see http://doc.babylonjs.com/how_to/multi_materials
  92508. */
  92509. subMeshes: SubMesh[];
  92510. /** @hidden */
  92511. _intersectionsInProgress: AbstractMesh[];
  92512. /** @hidden */
  92513. _unIndexed: boolean;
  92514. /** @hidden */
  92515. _lightSources: Light[];
  92516. /** Gets the list of lights affecting that mesh */
  92517. readonly lightSources: Light[];
  92518. /** @hidden */
  92519. readonly _positions: Nullable<Vector3[]>;
  92520. /** @hidden */
  92521. _waitingData: {
  92522. lods: Nullable<any>;
  92523. actions: Nullable<any>;
  92524. freezeWorldMatrix: Nullable<boolean>;
  92525. };
  92526. /** @hidden */
  92527. _bonesTransformMatrices: Nullable<Float32Array>;
  92528. /** @hidden */
  92529. _transformMatrixTexture: Nullable<RawTexture>;
  92530. /**
  92531. * Gets or sets a skeleton to apply skining transformations
  92532. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92533. */
  92534. skeleton: Nullable<Skeleton>;
  92535. /**
  92536. * An event triggered when the mesh is rebuilt.
  92537. */
  92538. onRebuildObservable: Observable<AbstractMesh>;
  92539. /**
  92540. * Creates a new AbstractMesh
  92541. * @param name defines the name of the mesh
  92542. * @param scene defines the hosting scene
  92543. */
  92544. constructor(name: string, scene?: Nullable<Scene>);
  92545. /**
  92546. * Returns the string "AbstractMesh"
  92547. * @returns "AbstractMesh"
  92548. */
  92549. getClassName(): string;
  92550. /**
  92551. * Gets a string representation of the current mesh
  92552. * @param fullDetails defines a boolean indicating if full details must be included
  92553. * @returns a string representation of the current mesh
  92554. */
  92555. toString(fullDetails?: boolean): string;
  92556. /**
  92557. * @hidden
  92558. */
  92559. protected _getEffectiveParent(): Nullable<Node>;
  92560. /** @hidden */
  92561. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92562. /** @hidden */
  92563. _rebuild(): void;
  92564. /** @hidden */
  92565. _resyncLightSources(): void;
  92566. /** @hidden */
  92567. _resyncLighSource(light: Light): void;
  92568. /** @hidden */
  92569. _unBindEffect(): void;
  92570. /** @hidden */
  92571. _removeLightSource(light: Light, dispose: boolean): void;
  92572. private _markSubMeshesAsDirty;
  92573. /** @hidden */
  92574. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  92575. /** @hidden */
  92576. _markSubMeshesAsAttributesDirty(): void;
  92577. /** @hidden */
  92578. _markSubMeshesAsMiscDirty(): void;
  92579. /**
  92580. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  92581. */
  92582. scaling: Vector3;
  92583. /**
  92584. * Returns true if the mesh is blocked. Implemented by child classes
  92585. */
  92586. readonly isBlocked: boolean;
  92587. /**
  92588. * Returns the mesh itself by default. Implemented by child classes
  92589. * @param camera defines the camera to use to pick the right LOD level
  92590. * @returns the currentAbstractMesh
  92591. */
  92592. getLOD(camera: Camera): Nullable<AbstractMesh>;
  92593. /**
  92594. * Returns 0 by default. Implemented by child classes
  92595. * @returns an integer
  92596. */
  92597. getTotalVertices(): number;
  92598. /**
  92599. * Returns a positive integer : the total number of indices in this mesh geometry.
  92600. * @returns the numner of indices or zero if the mesh has no geometry.
  92601. */
  92602. getTotalIndices(): number;
  92603. /**
  92604. * Returns null by default. Implemented by child classes
  92605. * @returns null
  92606. */
  92607. getIndices(): Nullable<IndicesArray>;
  92608. /**
  92609. * Returns the array of the requested vertex data kind. Implemented by child classes
  92610. * @param kind defines the vertex data kind to use
  92611. * @returns null
  92612. */
  92613. getVerticesData(kind: string): Nullable<FloatArray>;
  92614. /**
  92615. * Sets the vertex data of the mesh geometry for the requested `kind`.
  92616. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  92617. * Note that a new underlying VertexBuffer object is created each call.
  92618. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  92619. * @param kind defines vertex data kind:
  92620. * * VertexBuffer.PositionKind
  92621. * * VertexBuffer.UVKind
  92622. * * VertexBuffer.UV2Kind
  92623. * * VertexBuffer.UV3Kind
  92624. * * VertexBuffer.UV4Kind
  92625. * * VertexBuffer.UV5Kind
  92626. * * VertexBuffer.UV6Kind
  92627. * * VertexBuffer.ColorKind
  92628. * * VertexBuffer.MatricesIndicesKind
  92629. * * VertexBuffer.MatricesIndicesExtraKind
  92630. * * VertexBuffer.MatricesWeightsKind
  92631. * * VertexBuffer.MatricesWeightsExtraKind
  92632. * @param data defines the data source
  92633. * @param updatable defines if the data must be flagged as updatable (or static)
  92634. * @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
  92635. * @returns the current mesh
  92636. */
  92637. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92638. /**
  92639. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  92640. * If the mesh has no geometry, it is simply returned as it is.
  92641. * @param kind defines vertex data kind:
  92642. * * VertexBuffer.PositionKind
  92643. * * VertexBuffer.UVKind
  92644. * * VertexBuffer.UV2Kind
  92645. * * VertexBuffer.UV3Kind
  92646. * * VertexBuffer.UV4Kind
  92647. * * VertexBuffer.UV5Kind
  92648. * * VertexBuffer.UV6Kind
  92649. * * VertexBuffer.ColorKind
  92650. * * VertexBuffer.MatricesIndicesKind
  92651. * * VertexBuffer.MatricesIndicesExtraKind
  92652. * * VertexBuffer.MatricesWeightsKind
  92653. * * VertexBuffer.MatricesWeightsExtraKind
  92654. * @param data defines the data source
  92655. * @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
  92656. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  92657. * @returns the current mesh
  92658. */
  92659. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92660. /**
  92661. * Sets the mesh indices,
  92662. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  92663. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  92664. * @param totalVertices Defines the total number of vertices
  92665. * @returns the current mesh
  92666. */
  92667. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  92668. /**
  92669. * Gets a boolean indicating if specific vertex data is present
  92670. * @param kind defines the vertex data kind to use
  92671. * @returns true is data kind is present
  92672. */
  92673. isVerticesDataPresent(kind: string): boolean;
  92674. /**
  92675. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  92676. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  92677. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  92678. * @returns a BoundingInfo
  92679. */
  92680. getBoundingInfo(): BoundingInfo;
  92681. /**
  92682. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  92683. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  92684. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  92685. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  92686. * @returns the current mesh
  92687. */
  92688. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  92689. /**
  92690. * Overwrite the current bounding info
  92691. * @param boundingInfo defines the new bounding info
  92692. * @returns the current mesh
  92693. */
  92694. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  92695. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  92696. readonly useBones: boolean;
  92697. /** @hidden */
  92698. _preActivate(): void;
  92699. /** @hidden */
  92700. _preActivateForIntermediateRendering(renderId: number): void;
  92701. /** @hidden */
  92702. _activate(renderId: number, intermediateRendering: boolean): boolean;
  92703. /** @hidden */
  92704. _postActivate(): void;
  92705. /** @hidden */
  92706. _freeze(): void;
  92707. /** @hidden */
  92708. _unFreeze(): void;
  92709. /**
  92710. * Gets the current world matrix
  92711. * @returns a Matrix
  92712. */
  92713. getWorldMatrix(): Matrix;
  92714. /** @hidden */
  92715. _getWorldMatrixDeterminant(): number;
  92716. /**
  92717. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  92718. */
  92719. readonly isAnInstance: boolean;
  92720. /**
  92721. * Gets a boolean indicating if this mesh has instances
  92722. */
  92723. readonly hasInstances: boolean;
  92724. /**
  92725. * Perform relative position change from the point of view of behind the front of the mesh.
  92726. * This is performed taking into account the meshes current rotation, so you do not have to care.
  92727. * Supports definition of mesh facing forward or backward
  92728. * @param amountRight defines the distance on the right axis
  92729. * @param amountUp defines the distance on the up axis
  92730. * @param amountForward defines the distance on the forward axis
  92731. * @returns the current mesh
  92732. */
  92733. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  92734. /**
  92735. * Calculate relative position change from the point of view of behind the front of the mesh.
  92736. * This is performed taking into account the meshes current rotation, so you do not have to care.
  92737. * Supports definition of mesh facing forward or backward
  92738. * @param amountRight defines the distance on the right axis
  92739. * @param amountUp defines the distance on the up axis
  92740. * @param amountForward defines the distance on the forward axis
  92741. * @returns the new displacement vector
  92742. */
  92743. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  92744. /**
  92745. * Perform relative rotation change from the point of view of behind the front of the mesh.
  92746. * Supports definition of mesh facing forward or backward
  92747. * @param flipBack defines the flip
  92748. * @param twirlClockwise defines the twirl
  92749. * @param tiltRight defines the tilt
  92750. * @returns the current mesh
  92751. */
  92752. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  92753. /**
  92754. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  92755. * Supports definition of mesh facing forward or backward.
  92756. * @param flipBack defines the flip
  92757. * @param twirlClockwise defines the twirl
  92758. * @param tiltRight defines the tilt
  92759. * @returns the new rotation vector
  92760. */
  92761. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  92762. /**
  92763. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92764. * This means the mesh underlying bounding box and sphere are recomputed.
  92765. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92766. * @returns the current mesh
  92767. */
  92768. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  92769. /** @hidden */
  92770. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  92771. /** @hidden */
  92772. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  92773. /** @hidden */
  92774. _updateBoundingInfo(): AbstractMesh;
  92775. /** @hidden */
  92776. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  92777. /** @hidden */
  92778. protected _afterComputeWorldMatrix(): void;
  92779. /** @hidden */
  92780. readonly _effectiveMesh: AbstractMesh;
  92781. /**
  92782. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92783. * A mesh is in the frustum if its bounding box intersects the frustum
  92784. * @param frustumPlanes defines the frustum to test
  92785. * @returns true if the mesh is in the frustum planes
  92786. */
  92787. isInFrustum(frustumPlanes: Plane[]): boolean;
  92788. /**
  92789. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  92790. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  92791. * @param frustumPlanes defines the frustum to test
  92792. * @returns true if the mesh is completely in the frustum planes
  92793. */
  92794. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  92795. /**
  92796. * True if the mesh intersects another mesh or a SolidParticle object
  92797. * @param mesh defines a target mesh or SolidParticle to test
  92798. * @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)
  92799. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  92800. * @returns true if there is an intersection
  92801. */
  92802. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  92803. /**
  92804. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  92805. * @param point defines the point to test
  92806. * @returns true if there is an intersection
  92807. */
  92808. intersectsPoint(point: Vector3): boolean;
  92809. /**
  92810. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  92811. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92812. */
  92813. checkCollisions: boolean;
  92814. /**
  92815. * Gets Collider object used to compute collisions (not physics)
  92816. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92817. */
  92818. readonly collider: Nullable<Collider>;
  92819. /**
  92820. * Move the mesh using collision engine
  92821. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92822. * @param displacement defines the requested displacement vector
  92823. * @returns the current mesh
  92824. */
  92825. moveWithCollisions(displacement: Vector3): AbstractMesh;
  92826. private _onCollisionPositionChange;
  92827. /** @hidden */
  92828. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  92829. /** @hidden */
  92830. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  92831. /** @hidden */
  92832. _checkCollision(collider: Collider): AbstractMesh;
  92833. /** @hidden */
  92834. _generatePointsArray(): boolean;
  92835. /**
  92836. * Checks if the passed Ray intersects with the mesh
  92837. * @param ray defines the ray to use
  92838. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  92839. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92840. * @returns the picking info
  92841. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  92842. */
  92843. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  92844. /**
  92845. * Clones the current mesh
  92846. * @param name defines the mesh name
  92847. * @param newParent defines the new mesh parent
  92848. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  92849. * @returns the new mesh
  92850. */
  92851. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  92852. /**
  92853. * Disposes all the submeshes of the current meshnp
  92854. * @returns the current mesh
  92855. */
  92856. releaseSubMeshes(): AbstractMesh;
  92857. /**
  92858. * Releases resources associated with this abstract mesh.
  92859. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92860. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92861. */
  92862. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92863. /**
  92864. * Adds the passed mesh as a child to the current mesh
  92865. * @param mesh defines the child mesh
  92866. * @returns the current mesh
  92867. */
  92868. addChild(mesh: AbstractMesh): AbstractMesh;
  92869. /**
  92870. * Removes the passed mesh from the current mesh children list
  92871. * @param mesh defines the child mesh
  92872. * @returns the current mesh
  92873. */
  92874. removeChild(mesh: AbstractMesh): AbstractMesh;
  92875. /** @hidden */
  92876. private _initFacetData;
  92877. /**
  92878. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  92879. * This method can be called within the render loop.
  92880. * 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
  92881. * @returns the current mesh
  92882. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92883. */
  92884. updateFacetData(): AbstractMesh;
  92885. /**
  92886. * Returns the facetLocalNormals array.
  92887. * The normals are expressed in the mesh local spac
  92888. * @returns an array of Vector3
  92889. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92890. */
  92891. getFacetLocalNormals(): Vector3[];
  92892. /**
  92893. * Returns the facetLocalPositions array.
  92894. * The facet positions are expressed in the mesh local space
  92895. * @returns an array of Vector3
  92896. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92897. */
  92898. getFacetLocalPositions(): Vector3[];
  92899. /**
  92900. * Returns the facetLocalPartioning array
  92901. * @returns an array of array of numbers
  92902. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92903. */
  92904. getFacetLocalPartitioning(): number[][];
  92905. /**
  92906. * Returns the i-th facet position in the world system.
  92907. * This method allocates a new Vector3 per call
  92908. * @param i defines the facet index
  92909. * @returns a new Vector3
  92910. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92911. */
  92912. getFacetPosition(i: number): Vector3;
  92913. /**
  92914. * Sets the reference Vector3 with the i-th facet position in the world system
  92915. * @param i defines the facet index
  92916. * @param ref defines the target vector
  92917. * @returns the current mesh
  92918. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92919. */
  92920. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  92921. /**
  92922. * Returns the i-th facet normal in the world system.
  92923. * This method allocates a new Vector3 per call
  92924. * @param i defines the facet index
  92925. * @returns a new Vector3
  92926. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92927. */
  92928. getFacetNormal(i: number): Vector3;
  92929. /**
  92930. * Sets the reference Vector3 with the i-th facet normal in the world system
  92931. * @param i defines the facet index
  92932. * @param ref defines the target vector
  92933. * @returns the current mesh
  92934. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92935. */
  92936. getFacetNormalToRef(i: number, ref: Vector3): this;
  92937. /**
  92938. * 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)
  92939. * @param x defines x coordinate
  92940. * @param y defines y coordinate
  92941. * @param z defines z coordinate
  92942. * @returns the array of facet indexes
  92943. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92944. */
  92945. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  92946. /**
  92947. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  92948. * @param projected sets as the (x,y,z) world projection on the facet
  92949. * @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
  92950. * @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
  92951. * @param x defines x coordinate
  92952. * @param y defines y coordinate
  92953. * @param z defines z coordinate
  92954. * @returns the face index if found (or null instead)
  92955. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92956. */
  92957. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92958. /**
  92959. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  92960. * @param projected sets as the (x,y,z) local projection on the facet
  92961. * @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
  92962. * @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
  92963. * @param x defines x coordinate
  92964. * @param y defines y coordinate
  92965. * @param z defines z coordinate
  92966. * @returns the face index if found (or null instead)
  92967. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92968. */
  92969. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92970. /**
  92971. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  92972. * @returns the parameters
  92973. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92974. */
  92975. getFacetDataParameters(): any;
  92976. /**
  92977. * Disables the feature FacetData and frees the related memory
  92978. * @returns the current mesh
  92979. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92980. */
  92981. disableFacetData(): AbstractMesh;
  92982. /**
  92983. * Updates the AbstractMesh indices array
  92984. * @param indices defines the data source
  92985. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92986. * @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)
  92987. * @returns the current mesh
  92988. */
  92989. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92990. /**
  92991. * Creates new normals data for the mesh
  92992. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  92993. * @returns the current mesh
  92994. */
  92995. createNormals(updatable: boolean): AbstractMesh;
  92996. /**
  92997. * Align the mesh with a normal
  92998. * @param normal defines the normal to use
  92999. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  93000. * @returns the current mesh
  93001. */
  93002. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  93003. /** @hidden */
  93004. _checkOcclusionQuery(): boolean;
  93005. /**
  93006. * Disables the mesh edge rendering mode
  93007. * @returns the currentAbstractMesh
  93008. */
  93009. disableEdgesRendering(): AbstractMesh;
  93010. /**
  93011. * Enables the edge rendering mode on the mesh.
  93012. * This mode makes the mesh edges visible
  93013. * @param epsilon defines the maximal distance between two angles to detect a face
  93014. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93015. * @returns the currentAbstractMesh
  93016. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93017. */
  93018. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93019. }
  93020. }
  93021. declare module BABYLON {
  93022. /**
  93023. * Interface used to define ActionEvent
  93024. */
  93025. export interface IActionEvent {
  93026. /** The mesh or sprite that triggered the action */
  93027. source: any;
  93028. /** The X mouse cursor position at the time of the event */
  93029. pointerX: number;
  93030. /** The Y mouse cursor position at the time of the event */
  93031. pointerY: number;
  93032. /** The mesh that is currently pointed at (can be null) */
  93033. meshUnderPointer: Nullable<AbstractMesh>;
  93034. /** the original (browser) event that triggered the ActionEvent */
  93035. sourceEvent?: any;
  93036. /** additional data for the event */
  93037. additionalData?: any;
  93038. }
  93039. /**
  93040. * ActionEvent is the event being sent when an action is triggered.
  93041. */
  93042. export class ActionEvent implements IActionEvent {
  93043. /** The mesh or sprite that triggered the action */
  93044. source: any;
  93045. /** The X mouse cursor position at the time of the event */
  93046. pointerX: number;
  93047. /** The Y mouse cursor position at the time of the event */
  93048. pointerY: number;
  93049. /** The mesh that is currently pointed at (can be null) */
  93050. meshUnderPointer: Nullable<AbstractMesh>;
  93051. /** the original (browser) event that triggered the ActionEvent */
  93052. sourceEvent?: any;
  93053. /** additional data for the event */
  93054. additionalData?: any;
  93055. /**
  93056. * Creates a new ActionEvent
  93057. * @param source The mesh or sprite that triggered the action
  93058. * @param pointerX The X mouse cursor position at the time of the event
  93059. * @param pointerY The Y mouse cursor position at the time of the event
  93060. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  93061. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  93062. * @param additionalData additional data for the event
  93063. */
  93064. constructor(
  93065. /** The mesh or sprite that triggered the action */
  93066. source: any,
  93067. /** The X mouse cursor position at the time of the event */
  93068. pointerX: number,
  93069. /** The Y mouse cursor position at the time of the event */
  93070. pointerY: number,
  93071. /** The mesh that is currently pointed at (can be null) */
  93072. meshUnderPointer: Nullable<AbstractMesh>,
  93073. /** the original (browser) event that triggered the ActionEvent */
  93074. sourceEvent?: any,
  93075. /** additional data for the event */
  93076. additionalData?: any);
  93077. /**
  93078. * Helper function to auto-create an ActionEvent from a source mesh.
  93079. * @param source The source mesh that triggered the event
  93080. * @param evt The original (browser) event
  93081. * @param additionalData additional data for the event
  93082. * @returns the new ActionEvent
  93083. */
  93084. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  93085. /**
  93086. * Helper function to auto-create an ActionEvent from a source sprite
  93087. * @param source The source sprite that triggered the event
  93088. * @param scene Scene associated with the sprite
  93089. * @param evt The original (browser) event
  93090. * @param additionalData additional data for the event
  93091. * @returns the new ActionEvent
  93092. */
  93093. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  93094. /**
  93095. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  93096. * @param scene the scene where the event occurred
  93097. * @param evt The original (browser) event
  93098. * @returns the new ActionEvent
  93099. */
  93100. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  93101. /**
  93102. * Helper function to auto-create an ActionEvent from a primitive
  93103. * @param prim defines the target primitive
  93104. * @param pointerPos defines the pointer position
  93105. * @param evt The original (browser) event
  93106. * @param additionalData additional data for the event
  93107. * @returns the new ActionEvent
  93108. */
  93109. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  93110. }
  93111. }
  93112. declare module BABYLON {
  93113. /**
  93114. * Abstract class used to decouple action Manager from scene and meshes.
  93115. * Do not instantiate.
  93116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93117. */
  93118. export abstract class AbstractActionManager implements IDisposable {
  93119. /** Gets the list of active triggers */
  93120. static Triggers: {
  93121. [key: string]: number;
  93122. };
  93123. /** Gets the cursor to use when hovering items */
  93124. hoverCursor: string;
  93125. /** Gets the list of actions */
  93126. actions: IAction[];
  93127. /**
  93128. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  93129. */
  93130. isRecursive: boolean;
  93131. /**
  93132. * Releases all associated resources
  93133. */
  93134. abstract dispose(): void;
  93135. /**
  93136. * Does this action manager has pointer triggers
  93137. */
  93138. abstract readonly hasPointerTriggers: boolean;
  93139. /**
  93140. * Does this action manager has pick triggers
  93141. */
  93142. abstract readonly hasPickTriggers: boolean;
  93143. /**
  93144. * Process a specific trigger
  93145. * @param trigger defines the trigger to process
  93146. * @param evt defines the event details to be processed
  93147. */
  93148. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  93149. /**
  93150. * Does this action manager handles actions of any of the given triggers
  93151. * @param triggers defines the triggers to be tested
  93152. * @return a boolean indicating whether one (or more) of the triggers is handled
  93153. */
  93154. abstract hasSpecificTriggers(triggers: number[]): boolean;
  93155. /**
  93156. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  93157. * speed.
  93158. * @param triggerA defines the trigger to be tested
  93159. * @param triggerB defines the trigger to be tested
  93160. * @return a boolean indicating whether one (or more) of the triggers is handled
  93161. */
  93162. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  93163. /**
  93164. * Does this action manager handles actions of a given trigger
  93165. * @param trigger defines the trigger to be tested
  93166. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  93167. * @return whether the trigger is handled
  93168. */
  93169. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  93170. /**
  93171. * Serialize this manager to a JSON object
  93172. * @param name defines the property name to store this manager
  93173. * @returns a JSON representation of this manager
  93174. */
  93175. abstract serialize(name: string): any;
  93176. /**
  93177. * Registers an action to this action manager
  93178. * @param action defines the action to be registered
  93179. * @return the action amended (prepared) after registration
  93180. */
  93181. abstract registerAction(action: IAction): Nullable<IAction>;
  93182. /**
  93183. * Unregisters an action to this action manager
  93184. * @param action defines the action to be unregistered
  93185. * @return a boolean indicating whether the action has been unregistered
  93186. */
  93187. abstract unregisterAction(action: IAction): Boolean;
  93188. /**
  93189. * Does exist one action manager with at least one trigger
  93190. **/
  93191. static readonly HasTriggers: boolean;
  93192. /**
  93193. * Does exist one action manager with at least one pick trigger
  93194. **/
  93195. static readonly HasPickTriggers: boolean;
  93196. /**
  93197. * Does exist one action manager that handles actions of a given trigger
  93198. * @param trigger defines the trigger to be tested
  93199. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  93200. **/
  93201. static HasSpecificTrigger(trigger: number): boolean;
  93202. }
  93203. }
  93204. declare module BABYLON {
  93205. /**
  93206. * Defines how a node can be built from a string name.
  93207. */
  93208. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  93209. /**
  93210. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  93211. */
  93212. export class Node implements IBehaviorAware<Node> {
  93213. /** @hidden */
  93214. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  93215. private static _NodeConstructors;
  93216. /**
  93217. * Add a new node constructor
  93218. * @param type defines the type name of the node to construct
  93219. * @param constructorFunc defines the constructor function
  93220. */
  93221. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  93222. /**
  93223. * Returns a node constructor based on type name
  93224. * @param type defines the type name
  93225. * @param name defines the new node name
  93226. * @param scene defines the hosting scene
  93227. * @param options defines optional options to transmit to constructors
  93228. * @returns the new constructor or null
  93229. */
  93230. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  93231. /**
  93232. * Gets or sets the name of the node
  93233. */
  93234. name: string;
  93235. /**
  93236. * Gets or sets the id of the node
  93237. */
  93238. id: string;
  93239. /**
  93240. * Gets or sets the unique id of the node
  93241. */
  93242. uniqueId: number;
  93243. /**
  93244. * Gets or sets a string used to store user defined state for the node
  93245. */
  93246. state: string;
  93247. /**
  93248. * Gets or sets an object used to store user defined information for the node
  93249. */
  93250. metadata: any;
  93251. /**
  93252. * For internal use only. Please do not use.
  93253. */
  93254. reservedDataStore: any;
  93255. /**
  93256. * List of inspectable custom properties (used by the Inspector)
  93257. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93258. */
  93259. inspectableCustomProperties: IInspectable[];
  93260. /**
  93261. * Gets or sets a boolean used to define if the node must be serialized
  93262. */
  93263. doNotSerialize: boolean;
  93264. /** @hidden */
  93265. _isDisposed: boolean;
  93266. /**
  93267. * Gets a list of Animations associated with the node
  93268. */
  93269. animations: Animation[];
  93270. protected _ranges: {
  93271. [name: string]: Nullable<AnimationRange>;
  93272. };
  93273. /**
  93274. * Callback raised when the node is ready to be used
  93275. */
  93276. onReady: Nullable<(node: Node) => void>;
  93277. private _isEnabled;
  93278. private _isParentEnabled;
  93279. private _isReady;
  93280. /** @hidden */
  93281. _currentRenderId: number;
  93282. private _parentUpdateId;
  93283. /** @hidden */
  93284. _childUpdateId: number;
  93285. /** @hidden */
  93286. _waitingParentId: Nullable<string>;
  93287. /** @hidden */
  93288. _scene: Scene;
  93289. /** @hidden */
  93290. _cache: any;
  93291. private _parentNode;
  93292. private _children;
  93293. /** @hidden */
  93294. _worldMatrix: Matrix;
  93295. /** @hidden */
  93296. _worldMatrixDeterminant: number;
  93297. /** @hidden */
  93298. _worldMatrixDeterminantIsDirty: boolean;
  93299. /** @hidden */
  93300. private _sceneRootNodesIndex;
  93301. /**
  93302. * Gets a boolean indicating if the node has been disposed
  93303. * @returns true if the node was disposed
  93304. */
  93305. isDisposed(): boolean;
  93306. /**
  93307. * Gets or sets the parent of the node (without keeping the current position in the scene)
  93308. * @see https://doc.babylonjs.com/how_to/parenting
  93309. */
  93310. parent: Nullable<Node>;
  93311. private addToSceneRootNodes;
  93312. private removeFromSceneRootNodes;
  93313. private _animationPropertiesOverride;
  93314. /**
  93315. * Gets or sets the animation properties override
  93316. */
  93317. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  93318. /**
  93319. * Gets a string idenfifying the name of the class
  93320. * @returns "Node" string
  93321. */
  93322. getClassName(): string;
  93323. /** @hidden */
  93324. readonly _isNode: boolean;
  93325. /**
  93326. * An event triggered when the mesh is disposed
  93327. */
  93328. onDisposeObservable: Observable<Node>;
  93329. private _onDisposeObserver;
  93330. /**
  93331. * Sets a callback that will be raised when the node will be disposed
  93332. */
  93333. onDispose: () => void;
  93334. /**
  93335. * Creates a new Node
  93336. * @param name the name and id to be given to this node
  93337. * @param scene the scene this node will be added to
  93338. * @param addToRootNodes the node will be added to scene.rootNodes
  93339. */
  93340. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  93341. /**
  93342. * Gets the scene of the node
  93343. * @returns a scene
  93344. */
  93345. getScene(): Scene;
  93346. /**
  93347. * Gets the engine of the node
  93348. * @returns a Engine
  93349. */
  93350. getEngine(): Engine;
  93351. private _behaviors;
  93352. /**
  93353. * Attach a behavior to the node
  93354. * @see http://doc.babylonjs.com/features/behaviour
  93355. * @param behavior defines the behavior to attach
  93356. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  93357. * @returns the current Node
  93358. */
  93359. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  93360. /**
  93361. * Remove an attached behavior
  93362. * @see http://doc.babylonjs.com/features/behaviour
  93363. * @param behavior defines the behavior to attach
  93364. * @returns the current Node
  93365. */
  93366. removeBehavior(behavior: Behavior<Node>): Node;
  93367. /**
  93368. * Gets the list of attached behaviors
  93369. * @see http://doc.babylonjs.com/features/behaviour
  93370. */
  93371. readonly behaviors: Behavior<Node>[];
  93372. /**
  93373. * Gets an attached behavior by name
  93374. * @param name defines the name of the behavior to look for
  93375. * @see http://doc.babylonjs.com/features/behaviour
  93376. * @returns null if behavior was not found else the requested behavior
  93377. */
  93378. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  93379. /**
  93380. * Returns the latest update of the World matrix
  93381. * @returns a Matrix
  93382. */
  93383. getWorldMatrix(): Matrix;
  93384. /** @hidden */
  93385. _getWorldMatrixDeterminant(): number;
  93386. /**
  93387. * Returns directly the latest state of the mesh World matrix.
  93388. * A Matrix is returned.
  93389. */
  93390. readonly worldMatrixFromCache: Matrix;
  93391. /** @hidden */
  93392. _initCache(): void;
  93393. /** @hidden */
  93394. updateCache(force?: boolean): void;
  93395. /** @hidden */
  93396. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93397. /** @hidden */
  93398. _updateCache(ignoreParentClass?: boolean): void;
  93399. /** @hidden */
  93400. _isSynchronized(): boolean;
  93401. /** @hidden */
  93402. _markSyncedWithParent(): void;
  93403. /** @hidden */
  93404. isSynchronizedWithParent(): boolean;
  93405. /** @hidden */
  93406. isSynchronized(): boolean;
  93407. /**
  93408. * Is this node ready to be used/rendered
  93409. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93410. * @return true if the node is ready
  93411. */
  93412. isReady(completeCheck?: boolean): boolean;
  93413. /**
  93414. * Is this node enabled?
  93415. * 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
  93416. * @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
  93417. * @return whether this node (and its parent) is enabled
  93418. */
  93419. isEnabled(checkAncestors?: boolean): boolean;
  93420. /** @hidden */
  93421. protected _syncParentEnabledState(): void;
  93422. /**
  93423. * Set the enabled state of this node
  93424. * @param value defines the new enabled state
  93425. */
  93426. setEnabled(value: boolean): void;
  93427. /**
  93428. * Is this node a descendant of the given node?
  93429. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  93430. * @param ancestor defines the parent node to inspect
  93431. * @returns a boolean indicating if this node is a descendant of the given node
  93432. */
  93433. isDescendantOf(ancestor: Node): boolean;
  93434. /** @hidden */
  93435. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  93436. /**
  93437. * Will return all nodes that have this node as ascendant
  93438. * @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
  93439. * @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
  93440. * @return all children nodes of all types
  93441. */
  93442. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  93443. /**
  93444. * Get all child-meshes of this node
  93445. * @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)
  93446. * @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
  93447. * @returns an array of AbstractMesh
  93448. */
  93449. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  93450. /**
  93451. * Get all direct children of this node
  93452. * @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
  93453. * @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)
  93454. * @returns an array of Node
  93455. */
  93456. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  93457. /** @hidden */
  93458. _setReady(state: boolean): void;
  93459. /**
  93460. * Get an animation by name
  93461. * @param name defines the name of the animation to look for
  93462. * @returns null if not found else the requested animation
  93463. */
  93464. getAnimationByName(name: string): Nullable<Animation>;
  93465. /**
  93466. * Creates an animation range for this node
  93467. * @param name defines the name of the range
  93468. * @param from defines the starting key
  93469. * @param to defines the end key
  93470. */
  93471. createAnimationRange(name: string, from: number, to: number): void;
  93472. /**
  93473. * Delete a specific animation range
  93474. * @param name defines the name of the range to delete
  93475. * @param deleteFrames defines if animation frames from the range must be deleted as well
  93476. */
  93477. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93478. /**
  93479. * Get an animation range by name
  93480. * @param name defines the name of the animation range to look for
  93481. * @returns null if not found else the requested animation range
  93482. */
  93483. getAnimationRange(name: string): Nullable<AnimationRange>;
  93484. /**
  93485. * Gets the list of all animation ranges defined on this node
  93486. * @returns an array
  93487. */
  93488. getAnimationRanges(): Nullable<AnimationRange>[];
  93489. /**
  93490. * Will start the animation sequence
  93491. * @param name defines the range frames for animation sequence
  93492. * @param loop defines if the animation should loop (false by default)
  93493. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  93494. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  93495. * @returns the object created for this animation. If range does not exist, it will return null
  93496. */
  93497. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93498. /**
  93499. * Serialize animation ranges into a JSON compatible object
  93500. * @returns serialization object
  93501. */
  93502. serializeAnimationRanges(): any;
  93503. /**
  93504. * Computes the world matrix of the node
  93505. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93506. * @returns the world matrix
  93507. */
  93508. computeWorldMatrix(force?: boolean): Matrix;
  93509. /**
  93510. * Releases resources associated with this node.
  93511. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93512. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93513. */
  93514. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93515. /**
  93516. * Parse animation range data from a serialization object and store them into a given node
  93517. * @param node defines where to store the animation ranges
  93518. * @param parsedNode defines the serialization object to read data from
  93519. * @param scene defines the hosting scene
  93520. */
  93521. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  93522. /**
  93523. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  93524. * @param includeDescendants Include bounding info from descendants as well (true by default)
  93525. * @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
  93526. * @returns the new bounding vectors
  93527. */
  93528. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  93529. min: Vector3;
  93530. max: Vector3;
  93531. };
  93532. }
  93533. }
  93534. declare module BABYLON {
  93535. /**
  93536. * @hidden
  93537. */
  93538. export class _IAnimationState {
  93539. key: number;
  93540. repeatCount: number;
  93541. workValue?: any;
  93542. loopMode?: number;
  93543. offsetValue?: any;
  93544. highLimitValue?: any;
  93545. }
  93546. /**
  93547. * Class used to store any kind of animation
  93548. */
  93549. export class Animation {
  93550. /**Name of the animation */
  93551. name: string;
  93552. /**Property to animate */
  93553. targetProperty: string;
  93554. /**The frames per second of the animation */
  93555. framePerSecond: number;
  93556. /**The data type of the animation */
  93557. dataType: number;
  93558. /**The loop mode of the animation */
  93559. loopMode?: number | undefined;
  93560. /**Specifies if blending should be enabled */
  93561. enableBlending?: boolean | undefined;
  93562. /**
  93563. * Use matrix interpolation instead of using direct key value when animating matrices
  93564. */
  93565. static AllowMatricesInterpolation: boolean;
  93566. /**
  93567. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  93568. */
  93569. static AllowMatrixDecomposeForInterpolation: boolean;
  93570. /**
  93571. * Stores the key frames of the animation
  93572. */
  93573. private _keys;
  93574. /**
  93575. * Stores the easing function of the animation
  93576. */
  93577. private _easingFunction;
  93578. /**
  93579. * @hidden Internal use only
  93580. */
  93581. _runtimeAnimations: RuntimeAnimation[];
  93582. /**
  93583. * The set of event that will be linked to this animation
  93584. */
  93585. private _events;
  93586. /**
  93587. * Stores an array of target property paths
  93588. */
  93589. targetPropertyPath: string[];
  93590. /**
  93591. * Stores the blending speed of the animation
  93592. */
  93593. blendingSpeed: number;
  93594. /**
  93595. * Stores the animation ranges for the animation
  93596. */
  93597. private _ranges;
  93598. /**
  93599. * @hidden Internal use
  93600. */
  93601. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  93602. /**
  93603. * Sets up an animation
  93604. * @param property The property to animate
  93605. * @param animationType The animation type to apply
  93606. * @param framePerSecond The frames per second of the animation
  93607. * @param easingFunction The easing function used in the animation
  93608. * @returns The created animation
  93609. */
  93610. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  93611. /**
  93612. * Create and start an animation on a node
  93613. * @param name defines the name of the global animation that will be run on all nodes
  93614. * @param node defines the root node where the animation will take place
  93615. * @param targetProperty defines property to animate
  93616. * @param framePerSecond defines the number of frame per second yo use
  93617. * @param totalFrame defines the number of frames in total
  93618. * @param from defines the initial value
  93619. * @param to defines the final value
  93620. * @param loopMode defines which loop mode you want to use (off by default)
  93621. * @param easingFunction defines the easing function to use (linear by default)
  93622. * @param onAnimationEnd defines the callback to call when animation end
  93623. * @returns the animatable created for this animation
  93624. */
  93625. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93626. /**
  93627. * Create and start an animation on a node and its descendants
  93628. * @param name defines the name of the global animation that will be run on all nodes
  93629. * @param node defines the root node where the animation will take place
  93630. * @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
  93631. * @param targetProperty defines property to animate
  93632. * @param framePerSecond defines the number of frame per second to use
  93633. * @param totalFrame defines the number of frames in total
  93634. * @param from defines the initial value
  93635. * @param to defines the final value
  93636. * @param loopMode defines which loop mode you want to use (off by default)
  93637. * @param easingFunction defines the easing function to use (linear by default)
  93638. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93639. * @returns the list of animatables created for all nodes
  93640. * @example https://www.babylonjs-playground.com/#MH0VLI
  93641. */
  93642. 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[]>;
  93643. /**
  93644. * Creates a new animation, merges it with the existing animations and starts it
  93645. * @param name Name of the animation
  93646. * @param node Node which contains the scene that begins the animations
  93647. * @param targetProperty Specifies which property to animate
  93648. * @param framePerSecond The frames per second of the animation
  93649. * @param totalFrame The total number of frames
  93650. * @param from The frame at the beginning of the animation
  93651. * @param to The frame at the end of the animation
  93652. * @param loopMode Specifies the loop mode of the animation
  93653. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  93654. * @param onAnimationEnd Callback to run once the animation is complete
  93655. * @returns Nullable animation
  93656. */
  93657. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93658. /**
  93659. * Transition property of an host to the target Value
  93660. * @param property The property to transition
  93661. * @param targetValue The target Value of the property
  93662. * @param host The object where the property to animate belongs
  93663. * @param scene Scene used to run the animation
  93664. * @param frameRate Framerate (in frame/s) to use
  93665. * @param transition The transition type we want to use
  93666. * @param duration The duration of the animation, in milliseconds
  93667. * @param onAnimationEnd Callback trigger at the end of the animation
  93668. * @returns Nullable animation
  93669. */
  93670. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  93671. /**
  93672. * Return the array of runtime animations currently using this animation
  93673. */
  93674. readonly runtimeAnimations: RuntimeAnimation[];
  93675. /**
  93676. * Specifies if any of the runtime animations are currently running
  93677. */
  93678. readonly hasRunningRuntimeAnimations: boolean;
  93679. /**
  93680. * Initializes the animation
  93681. * @param name Name of the animation
  93682. * @param targetProperty Property to animate
  93683. * @param framePerSecond The frames per second of the animation
  93684. * @param dataType The data type of the animation
  93685. * @param loopMode The loop mode of the animation
  93686. * @param enableBlending Specifies if blending should be enabled
  93687. */
  93688. constructor(
  93689. /**Name of the animation */
  93690. name: string,
  93691. /**Property to animate */
  93692. targetProperty: string,
  93693. /**The frames per second of the animation */
  93694. framePerSecond: number,
  93695. /**The data type of the animation */
  93696. dataType: number,
  93697. /**The loop mode of the animation */
  93698. loopMode?: number | undefined,
  93699. /**Specifies if blending should be enabled */
  93700. enableBlending?: boolean | undefined);
  93701. /**
  93702. * Converts the animation to a string
  93703. * @param fullDetails support for multiple levels of logging within scene loading
  93704. * @returns String form of the animation
  93705. */
  93706. toString(fullDetails?: boolean): string;
  93707. /**
  93708. * Add an event to this animation
  93709. * @param event Event to add
  93710. */
  93711. addEvent(event: AnimationEvent): void;
  93712. /**
  93713. * Remove all events found at the given frame
  93714. * @param frame The frame to remove events from
  93715. */
  93716. removeEvents(frame: number): void;
  93717. /**
  93718. * Retrieves all the events from the animation
  93719. * @returns Events from the animation
  93720. */
  93721. getEvents(): AnimationEvent[];
  93722. /**
  93723. * Creates an animation range
  93724. * @param name Name of the animation range
  93725. * @param from Starting frame of the animation range
  93726. * @param to Ending frame of the animation
  93727. */
  93728. createRange(name: string, from: number, to: number): void;
  93729. /**
  93730. * Deletes an animation range by name
  93731. * @param name Name of the animation range to delete
  93732. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  93733. */
  93734. deleteRange(name: string, deleteFrames?: boolean): void;
  93735. /**
  93736. * Gets the animation range by name, or null if not defined
  93737. * @param name Name of the animation range
  93738. * @returns Nullable animation range
  93739. */
  93740. getRange(name: string): Nullable<AnimationRange>;
  93741. /**
  93742. * Gets the key frames from the animation
  93743. * @returns The key frames of the animation
  93744. */
  93745. getKeys(): Array<IAnimationKey>;
  93746. /**
  93747. * Gets the highest frame rate of the animation
  93748. * @returns Highest frame rate of the animation
  93749. */
  93750. getHighestFrame(): number;
  93751. /**
  93752. * Gets the easing function of the animation
  93753. * @returns Easing function of the animation
  93754. */
  93755. getEasingFunction(): IEasingFunction;
  93756. /**
  93757. * Sets the easing function of the animation
  93758. * @param easingFunction A custom mathematical formula for animation
  93759. */
  93760. setEasingFunction(easingFunction: EasingFunction): void;
  93761. /**
  93762. * Interpolates a scalar linearly
  93763. * @param startValue Start value of the animation curve
  93764. * @param endValue End value of the animation curve
  93765. * @param gradient Scalar amount to interpolate
  93766. * @returns Interpolated scalar value
  93767. */
  93768. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  93769. /**
  93770. * Interpolates a scalar cubically
  93771. * @param startValue Start value of the animation curve
  93772. * @param outTangent End tangent of the animation
  93773. * @param endValue End value of the animation curve
  93774. * @param inTangent Start tangent of the animation curve
  93775. * @param gradient Scalar amount to interpolate
  93776. * @returns Interpolated scalar value
  93777. */
  93778. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  93779. /**
  93780. * Interpolates a quaternion using a spherical linear interpolation
  93781. * @param startValue Start value of the animation curve
  93782. * @param endValue End value of the animation curve
  93783. * @param gradient Scalar amount to interpolate
  93784. * @returns Interpolated quaternion value
  93785. */
  93786. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  93787. /**
  93788. * Interpolates a quaternion cubically
  93789. * @param startValue Start value of the animation curve
  93790. * @param outTangent End tangent of the animation curve
  93791. * @param endValue End value of the animation curve
  93792. * @param inTangent Start tangent of the animation curve
  93793. * @param gradient Scalar amount to interpolate
  93794. * @returns Interpolated quaternion value
  93795. */
  93796. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  93797. /**
  93798. * Interpolates a Vector3 linearl
  93799. * @param startValue Start value of the animation curve
  93800. * @param endValue End value of the animation curve
  93801. * @param gradient Scalar amount to interpolate
  93802. * @returns Interpolated scalar value
  93803. */
  93804. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  93805. /**
  93806. * Interpolates a Vector3 cubically
  93807. * @param startValue Start value of the animation curve
  93808. * @param outTangent End tangent of the animation
  93809. * @param endValue End value of the animation curve
  93810. * @param inTangent Start tangent of the animation curve
  93811. * @param gradient Scalar amount to interpolate
  93812. * @returns InterpolatedVector3 value
  93813. */
  93814. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  93815. /**
  93816. * Interpolates a Vector2 linearly
  93817. * @param startValue Start value of the animation curve
  93818. * @param endValue End value of the animation curve
  93819. * @param gradient Scalar amount to interpolate
  93820. * @returns Interpolated Vector2 value
  93821. */
  93822. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  93823. /**
  93824. * Interpolates a Vector2 cubically
  93825. * @param startValue Start value of the animation curve
  93826. * @param outTangent End tangent of the animation
  93827. * @param endValue End value of the animation curve
  93828. * @param inTangent Start tangent of the animation curve
  93829. * @param gradient Scalar amount to interpolate
  93830. * @returns Interpolated Vector2 value
  93831. */
  93832. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  93833. /**
  93834. * Interpolates a size linearly
  93835. * @param startValue Start value of the animation curve
  93836. * @param endValue End value of the animation curve
  93837. * @param gradient Scalar amount to interpolate
  93838. * @returns Interpolated Size value
  93839. */
  93840. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  93841. /**
  93842. * Interpolates a Color3 linearly
  93843. * @param startValue Start value of the animation curve
  93844. * @param endValue End value of the animation curve
  93845. * @param gradient Scalar amount to interpolate
  93846. * @returns Interpolated Color3 value
  93847. */
  93848. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  93849. /**
  93850. * @hidden Internal use only
  93851. */
  93852. _getKeyValue(value: any): any;
  93853. /**
  93854. * @hidden Internal use only
  93855. */
  93856. _interpolate(currentFrame: number, state: _IAnimationState): any;
  93857. /**
  93858. * Defines the function to use to interpolate matrices
  93859. * @param startValue defines the start matrix
  93860. * @param endValue defines the end matrix
  93861. * @param gradient defines the gradient between both matrices
  93862. * @param result defines an optional target matrix where to store the interpolation
  93863. * @returns the interpolated matrix
  93864. */
  93865. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  93866. /**
  93867. * Makes a copy of the animation
  93868. * @returns Cloned animation
  93869. */
  93870. clone(): Animation;
  93871. /**
  93872. * Sets the key frames of the animation
  93873. * @param values The animation key frames to set
  93874. */
  93875. setKeys(values: Array<IAnimationKey>): void;
  93876. /**
  93877. * Serializes the animation to an object
  93878. * @returns Serialized object
  93879. */
  93880. serialize(): any;
  93881. /**
  93882. * Float animation type
  93883. */
  93884. private static _ANIMATIONTYPE_FLOAT;
  93885. /**
  93886. * Vector3 animation type
  93887. */
  93888. private static _ANIMATIONTYPE_VECTOR3;
  93889. /**
  93890. * Quaternion animation type
  93891. */
  93892. private static _ANIMATIONTYPE_QUATERNION;
  93893. /**
  93894. * Matrix animation type
  93895. */
  93896. private static _ANIMATIONTYPE_MATRIX;
  93897. /**
  93898. * Color3 animation type
  93899. */
  93900. private static _ANIMATIONTYPE_COLOR3;
  93901. /**
  93902. * Vector2 animation type
  93903. */
  93904. private static _ANIMATIONTYPE_VECTOR2;
  93905. /**
  93906. * Size animation type
  93907. */
  93908. private static _ANIMATIONTYPE_SIZE;
  93909. /**
  93910. * Relative Loop Mode
  93911. */
  93912. private static _ANIMATIONLOOPMODE_RELATIVE;
  93913. /**
  93914. * Cycle Loop Mode
  93915. */
  93916. private static _ANIMATIONLOOPMODE_CYCLE;
  93917. /**
  93918. * Constant Loop Mode
  93919. */
  93920. private static _ANIMATIONLOOPMODE_CONSTANT;
  93921. /**
  93922. * Get the float animation type
  93923. */
  93924. static readonly ANIMATIONTYPE_FLOAT: number;
  93925. /**
  93926. * Get the Vector3 animation type
  93927. */
  93928. static readonly ANIMATIONTYPE_VECTOR3: number;
  93929. /**
  93930. * Get the Vector2 animation type
  93931. */
  93932. static readonly ANIMATIONTYPE_VECTOR2: number;
  93933. /**
  93934. * Get the Size animation type
  93935. */
  93936. static readonly ANIMATIONTYPE_SIZE: number;
  93937. /**
  93938. * Get the Quaternion animation type
  93939. */
  93940. static readonly ANIMATIONTYPE_QUATERNION: number;
  93941. /**
  93942. * Get the Matrix animation type
  93943. */
  93944. static readonly ANIMATIONTYPE_MATRIX: number;
  93945. /**
  93946. * Get the Color3 animation type
  93947. */
  93948. static readonly ANIMATIONTYPE_COLOR3: number;
  93949. /**
  93950. * Get the Relative Loop Mode
  93951. */
  93952. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  93953. /**
  93954. * Get the Cycle Loop Mode
  93955. */
  93956. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  93957. /**
  93958. * Get the Constant Loop Mode
  93959. */
  93960. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  93961. /** @hidden */
  93962. static _UniversalLerp(left: any, right: any, amount: number): any;
  93963. /**
  93964. * Parses an animation object and creates an animation
  93965. * @param parsedAnimation Parsed animation object
  93966. * @returns Animation object
  93967. */
  93968. static Parse(parsedAnimation: any): Animation;
  93969. /**
  93970. * Appends the serialized animations from the source animations
  93971. * @param source Source containing the animations
  93972. * @param destination Target to store the animations
  93973. */
  93974. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93975. }
  93976. }
  93977. declare module BABYLON {
  93978. /**
  93979. * Interface containing an array of animations
  93980. */
  93981. export interface IAnimatable {
  93982. /**
  93983. * Array of animations
  93984. */
  93985. animations: Nullable<Array<Animation>>;
  93986. }
  93987. }
  93988. declare module BABYLON {
  93989. /**
  93990. * This represents all the required information to add a fresnel effect on a material:
  93991. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93992. */
  93993. export class FresnelParameters {
  93994. private _isEnabled;
  93995. /**
  93996. * Define if the fresnel effect is enable or not.
  93997. */
  93998. isEnabled: boolean;
  93999. /**
  94000. * Define the color used on edges (grazing angle)
  94001. */
  94002. leftColor: Color3;
  94003. /**
  94004. * Define the color used on center
  94005. */
  94006. rightColor: Color3;
  94007. /**
  94008. * Define bias applied to computed fresnel term
  94009. */
  94010. bias: number;
  94011. /**
  94012. * Defined the power exponent applied to fresnel term
  94013. */
  94014. power: number;
  94015. /**
  94016. * Clones the current fresnel and its valuues
  94017. * @returns a clone fresnel configuration
  94018. */
  94019. clone(): FresnelParameters;
  94020. /**
  94021. * Serializes the current fresnel parameters to a JSON representation.
  94022. * @return the JSON serialization
  94023. */
  94024. serialize(): any;
  94025. /**
  94026. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94027. * @param parsedFresnelParameters Define the JSON representation
  94028. * @returns the parsed parameters
  94029. */
  94030. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94031. }
  94032. }
  94033. declare module BABYLON {
  94034. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  94035. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94036. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94037. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94038. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94039. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94040. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94041. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94042. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94043. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94044. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94045. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94046. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94047. /**
  94048. * Decorator used to define property that can be serialized as reference to a camera
  94049. * @param sourceName defines the name of the property to decorate
  94050. */
  94051. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94052. /**
  94053. * Class used to help serialization objects
  94054. */
  94055. export class SerializationHelper {
  94056. /** @hidden */
  94057. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  94058. /** @hidden */
  94059. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  94060. /** @hidden */
  94061. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  94062. /** @hidden */
  94063. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  94064. /**
  94065. * Appends the serialized animations from the source animations
  94066. * @param source Source containing the animations
  94067. * @param destination Target to store the animations
  94068. */
  94069. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94070. /**
  94071. * Static function used to serialized a specific entity
  94072. * @param entity defines the entity to serialize
  94073. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  94074. * @returns a JSON compatible object representing the serialization of the entity
  94075. */
  94076. static Serialize<T>(entity: T, serializationObject?: any): any;
  94077. /**
  94078. * Creates a new entity from a serialization data object
  94079. * @param creationFunction defines a function used to instanciated the new entity
  94080. * @param source defines the source serialization data
  94081. * @param scene defines the hosting scene
  94082. * @param rootUrl defines the root url for resources
  94083. * @returns a new entity
  94084. */
  94085. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  94086. /**
  94087. * Clones an object
  94088. * @param creationFunction defines the function used to instanciate the new object
  94089. * @param source defines the source object
  94090. * @returns the cloned object
  94091. */
  94092. static Clone<T>(creationFunction: () => T, source: T): T;
  94093. /**
  94094. * Instanciates a new object based on a source one (some data will be shared between both object)
  94095. * @param creationFunction defines the function used to instanciate the new object
  94096. * @param source defines the source object
  94097. * @returns the new object
  94098. */
  94099. static Instanciate<T>(creationFunction: () => T, source: T): T;
  94100. }
  94101. }
  94102. declare module BABYLON {
  94103. /**
  94104. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  94105. */
  94106. export interface CubeMapInfo {
  94107. /**
  94108. * The pixel array for the front face.
  94109. * This is stored in format, left to right, up to down format.
  94110. */
  94111. front: Nullable<ArrayBufferView>;
  94112. /**
  94113. * The pixel array for the back face.
  94114. * This is stored in format, left to right, up to down format.
  94115. */
  94116. back: Nullable<ArrayBufferView>;
  94117. /**
  94118. * The pixel array for the left face.
  94119. * This is stored in format, left to right, up to down format.
  94120. */
  94121. left: Nullable<ArrayBufferView>;
  94122. /**
  94123. * The pixel array for the right face.
  94124. * This is stored in format, left to right, up to down format.
  94125. */
  94126. right: Nullable<ArrayBufferView>;
  94127. /**
  94128. * The pixel array for the up face.
  94129. * This is stored in format, left to right, up to down format.
  94130. */
  94131. up: Nullable<ArrayBufferView>;
  94132. /**
  94133. * The pixel array for the down face.
  94134. * This is stored in format, left to right, up to down format.
  94135. */
  94136. down: Nullable<ArrayBufferView>;
  94137. /**
  94138. * The size of the cubemap stored.
  94139. *
  94140. * Each faces will be size * size pixels.
  94141. */
  94142. size: number;
  94143. /**
  94144. * The format of the texture.
  94145. *
  94146. * RGBA, RGB.
  94147. */
  94148. format: number;
  94149. /**
  94150. * The type of the texture data.
  94151. *
  94152. * UNSIGNED_INT, FLOAT.
  94153. */
  94154. type: number;
  94155. /**
  94156. * Specifies whether the texture is in gamma space.
  94157. */
  94158. gammaSpace: boolean;
  94159. }
  94160. /**
  94161. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  94162. */
  94163. export class PanoramaToCubeMapTools {
  94164. private static FACE_FRONT;
  94165. private static FACE_BACK;
  94166. private static FACE_RIGHT;
  94167. private static FACE_LEFT;
  94168. private static FACE_DOWN;
  94169. private static FACE_UP;
  94170. /**
  94171. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  94172. *
  94173. * @param float32Array The source data.
  94174. * @param inputWidth The width of the input panorama.
  94175. * @param inputHeight The height of the input panorama.
  94176. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  94177. * @return The cubemap data
  94178. */
  94179. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  94180. private static CreateCubemapTexture;
  94181. private static CalcProjectionSpherical;
  94182. }
  94183. }
  94184. declare module BABYLON {
  94185. /**
  94186. * Helper class dealing with the extraction of spherical polynomial dataArray
  94187. * from a cube map.
  94188. */
  94189. export class CubeMapToSphericalPolynomialTools {
  94190. private static FileFaces;
  94191. /**
  94192. * Converts a texture to the according Spherical Polynomial data.
  94193. * This extracts the first 3 orders only as they are the only one used in the lighting.
  94194. *
  94195. * @param texture The texture to extract the information from.
  94196. * @return The Spherical Polynomial data.
  94197. */
  94198. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  94199. /**
  94200. * Converts a cubemap to the according Spherical Polynomial data.
  94201. * This extracts the first 3 orders only as they are the only one used in the lighting.
  94202. *
  94203. * @param cubeInfo The Cube map to extract the information from.
  94204. * @return The Spherical Polynomial data.
  94205. */
  94206. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  94207. }
  94208. }
  94209. declare module BABYLON {
  94210. /**
  94211. * Class used to manipulate GUIDs
  94212. */
  94213. export class GUID {
  94214. /**
  94215. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94216. * Be aware Math.random() could cause collisions, but:
  94217. * "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"
  94218. * @returns a pseudo random id
  94219. */
  94220. static RandomId(): string;
  94221. }
  94222. }
  94223. declare module BABYLON {
  94224. /**
  94225. * Base class of all the textures in babylon.
  94226. * It groups all the common properties the materials, post process, lights... might need
  94227. * in order to make a correct use of the texture.
  94228. */
  94229. export class BaseTexture implements IAnimatable {
  94230. /**
  94231. * Default anisotropic filtering level for the application.
  94232. * It is set to 4 as a good tradeoff between perf and quality.
  94233. */
  94234. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  94235. /**
  94236. * Gets or sets the unique id of the texture
  94237. */
  94238. uniqueId: number;
  94239. /**
  94240. * Define the name of the texture.
  94241. */
  94242. name: string;
  94243. /**
  94244. * Gets or sets an object used to store user defined information.
  94245. */
  94246. metadata: any;
  94247. /**
  94248. * For internal use only. Please do not use.
  94249. */
  94250. reservedDataStore: any;
  94251. private _hasAlpha;
  94252. /**
  94253. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  94254. */
  94255. hasAlpha: boolean;
  94256. /**
  94257. * Defines if the alpha value should be determined via the rgb values.
  94258. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  94259. */
  94260. getAlphaFromRGB: boolean;
  94261. /**
  94262. * Intensity or strength of the texture.
  94263. * It is commonly used by materials to fine tune the intensity of the texture
  94264. */
  94265. level: number;
  94266. /**
  94267. * Define the UV chanel to use starting from 0 and defaulting to 0.
  94268. * This is part of the texture as textures usually maps to one uv set.
  94269. */
  94270. coordinatesIndex: number;
  94271. private _coordinatesMode;
  94272. /**
  94273. * How a texture is mapped.
  94274. *
  94275. * | Value | Type | Description |
  94276. * | ----- | ----------------------------------- | ----------- |
  94277. * | 0 | EXPLICIT_MODE | |
  94278. * | 1 | SPHERICAL_MODE | |
  94279. * | 2 | PLANAR_MODE | |
  94280. * | 3 | CUBIC_MODE | |
  94281. * | 4 | PROJECTION_MODE | |
  94282. * | 5 | SKYBOX_MODE | |
  94283. * | 6 | INVCUBIC_MODE | |
  94284. * | 7 | EQUIRECTANGULAR_MODE | |
  94285. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  94286. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  94287. */
  94288. coordinatesMode: number;
  94289. /**
  94290. * | Value | Type | Description |
  94291. * | ----- | ------------------ | ----------- |
  94292. * | 0 | CLAMP_ADDRESSMODE | |
  94293. * | 1 | WRAP_ADDRESSMODE | |
  94294. * | 2 | MIRROR_ADDRESSMODE | |
  94295. */
  94296. wrapU: number;
  94297. /**
  94298. * | Value | Type | Description |
  94299. * | ----- | ------------------ | ----------- |
  94300. * | 0 | CLAMP_ADDRESSMODE | |
  94301. * | 1 | WRAP_ADDRESSMODE | |
  94302. * | 2 | MIRROR_ADDRESSMODE | |
  94303. */
  94304. wrapV: number;
  94305. /**
  94306. * | Value | Type | Description |
  94307. * | ----- | ------------------ | ----------- |
  94308. * | 0 | CLAMP_ADDRESSMODE | |
  94309. * | 1 | WRAP_ADDRESSMODE | |
  94310. * | 2 | MIRROR_ADDRESSMODE | |
  94311. */
  94312. wrapR: number;
  94313. /**
  94314. * With compliant hardware and browser (supporting anisotropic filtering)
  94315. * this defines the level of anisotropic filtering in the texture.
  94316. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  94317. */
  94318. anisotropicFilteringLevel: number;
  94319. /**
  94320. * Define if the texture is a cube texture or if false a 2d texture.
  94321. */
  94322. isCube: boolean;
  94323. /**
  94324. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  94325. */
  94326. is3D: boolean;
  94327. /**
  94328. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  94329. * HDR texture are usually stored in linear space.
  94330. * This only impacts the PBR and Background materials
  94331. */
  94332. gammaSpace: boolean;
  94333. /**
  94334. * Gets or sets whether or not the texture contains RGBD data.
  94335. */
  94336. isRGBD: boolean;
  94337. /**
  94338. * Is Z inverted in the texture (useful in a cube texture).
  94339. */
  94340. invertZ: boolean;
  94341. /**
  94342. * Are mip maps generated for this texture or not.
  94343. */
  94344. readonly noMipmap: boolean;
  94345. /**
  94346. * @hidden
  94347. */
  94348. lodLevelInAlpha: boolean;
  94349. /**
  94350. * With prefiltered texture, defined the offset used during the prefiltering steps.
  94351. */
  94352. lodGenerationOffset: number;
  94353. /**
  94354. * With prefiltered texture, defined the scale used during the prefiltering steps.
  94355. */
  94356. lodGenerationScale: number;
  94357. /**
  94358. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  94359. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  94360. * average roughness values.
  94361. */
  94362. linearSpecularLOD: boolean;
  94363. /**
  94364. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  94365. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  94366. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  94367. */
  94368. irradianceTexture: Nullable<BaseTexture>;
  94369. /**
  94370. * Define if the texture is a render target.
  94371. */
  94372. isRenderTarget: boolean;
  94373. /**
  94374. * Define the unique id of the texture in the scene.
  94375. */
  94376. readonly uid: string;
  94377. /**
  94378. * Return a string representation of the texture.
  94379. * @returns the texture as a string
  94380. */
  94381. toString(): string;
  94382. /**
  94383. * Get the class name of the texture.
  94384. * @returns "BaseTexture"
  94385. */
  94386. getClassName(): string;
  94387. /**
  94388. * Define the list of animation attached to the texture.
  94389. */
  94390. animations: Animation[];
  94391. /**
  94392. * An event triggered when the texture is disposed.
  94393. */
  94394. onDisposeObservable: Observable<BaseTexture>;
  94395. private _onDisposeObserver;
  94396. /**
  94397. * Callback triggered when the texture has been disposed.
  94398. * Kept for back compatibility, you can use the onDisposeObservable instead.
  94399. */
  94400. onDispose: () => void;
  94401. /**
  94402. * Define the current state of the loading sequence when in delayed load mode.
  94403. */
  94404. delayLoadState: number;
  94405. private _scene;
  94406. /** @hidden */
  94407. _texture: Nullable<InternalTexture>;
  94408. private _uid;
  94409. /**
  94410. * Define if the texture is preventinga material to render or not.
  94411. * If not and the texture is not ready, the engine will use a default black texture instead.
  94412. */
  94413. readonly isBlocking: boolean;
  94414. /**
  94415. * Instantiates a new BaseTexture.
  94416. * Base class of all the textures in babylon.
  94417. * It groups all the common properties the materials, post process, lights... might need
  94418. * in order to make a correct use of the texture.
  94419. * @param scene Define the scene the texture blongs to
  94420. */
  94421. constructor(scene: Nullable<Scene>);
  94422. /**
  94423. * Get the scene the texture belongs to.
  94424. * @returns the scene or null if undefined
  94425. */
  94426. getScene(): Nullable<Scene>;
  94427. /**
  94428. * Get the texture transform matrix used to offset tile the texture for istance.
  94429. * @returns the transformation matrix
  94430. */
  94431. getTextureMatrix(): Matrix;
  94432. /**
  94433. * Get the texture reflection matrix used to rotate/transform the reflection.
  94434. * @returns the reflection matrix
  94435. */
  94436. getReflectionTextureMatrix(): Matrix;
  94437. /**
  94438. * Get the underlying lower level texture from Babylon.
  94439. * @returns the insternal texture
  94440. */
  94441. getInternalTexture(): Nullable<InternalTexture>;
  94442. /**
  94443. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  94444. * @returns true if ready or not blocking
  94445. */
  94446. isReadyOrNotBlocking(): boolean;
  94447. /**
  94448. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  94449. * @returns true if fully ready
  94450. */
  94451. isReady(): boolean;
  94452. private _cachedSize;
  94453. /**
  94454. * Get the size of the texture.
  94455. * @returns the texture size.
  94456. */
  94457. getSize(): ISize;
  94458. /**
  94459. * Get the base size of the texture.
  94460. * It can be different from the size if the texture has been resized for POT for instance
  94461. * @returns the base size
  94462. */
  94463. getBaseSize(): ISize;
  94464. /**
  94465. * Update the sampling mode of the texture.
  94466. * Default is Trilinear mode.
  94467. *
  94468. * | Value | Type | Description |
  94469. * | ----- | ------------------ | ----------- |
  94470. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  94471. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  94472. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  94473. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  94474. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  94475. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  94476. * | 7 | NEAREST_LINEAR | |
  94477. * | 8 | NEAREST_NEAREST | |
  94478. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  94479. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  94480. * | 11 | LINEAR_LINEAR | |
  94481. * | 12 | LINEAR_NEAREST | |
  94482. *
  94483. * > _mag_: magnification filter (close to the viewer)
  94484. * > _min_: minification filter (far from the viewer)
  94485. * > _mip_: filter used between mip map levels
  94486. *@param samplingMode Define the new sampling mode of the texture
  94487. */
  94488. updateSamplingMode(samplingMode: number): void;
  94489. /**
  94490. * Scales the texture if is `canRescale()`
  94491. * @param ratio the resize factor we want to use to rescale
  94492. */
  94493. scale(ratio: number): void;
  94494. /**
  94495. * Get if the texture can rescale.
  94496. */
  94497. readonly canRescale: boolean;
  94498. /** @hidden */
  94499. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  94500. /** @hidden */
  94501. _rebuild(): void;
  94502. /**
  94503. * Triggers the load sequence in delayed load mode.
  94504. */
  94505. delayLoad(): void;
  94506. /**
  94507. * Clones the texture.
  94508. * @returns the cloned texture
  94509. */
  94510. clone(): Nullable<BaseTexture>;
  94511. /**
  94512. * Get the texture underlying type (INT, FLOAT...)
  94513. */
  94514. readonly textureType: number;
  94515. /**
  94516. * Get the texture underlying format (RGB, RGBA...)
  94517. */
  94518. readonly textureFormat: number;
  94519. /**
  94520. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  94521. * This will returns an RGBA array buffer containing either in values (0-255) or
  94522. * float values (0-1) depending of the underlying buffer type.
  94523. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  94524. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  94525. * @param buffer defines a user defined buffer to fill with data (can be null)
  94526. * @returns The Array buffer containing the pixels data.
  94527. */
  94528. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  94529. /**
  94530. * Release and destroy the underlying lower level texture aka internalTexture.
  94531. */
  94532. releaseInternalTexture(): void;
  94533. /**
  94534. * Get the polynomial representation of the texture data.
  94535. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  94536. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  94537. */
  94538. sphericalPolynomial: Nullable<SphericalPolynomial>;
  94539. /** @hidden */
  94540. readonly _lodTextureHigh: Nullable<BaseTexture>;
  94541. /** @hidden */
  94542. readonly _lodTextureMid: Nullable<BaseTexture>;
  94543. /** @hidden */
  94544. readonly _lodTextureLow: Nullable<BaseTexture>;
  94545. /**
  94546. * Dispose the texture and release its associated resources.
  94547. */
  94548. dispose(): void;
  94549. /**
  94550. * Serialize the texture into a JSON representation that can be parsed later on.
  94551. * @returns the JSON representation of the texture
  94552. */
  94553. serialize(): any;
  94554. /**
  94555. * Helper function to be called back once a list of texture contains only ready textures.
  94556. * @param textures Define the list of textures to wait for
  94557. * @param callback Define the callback triggered once the entire list will be ready
  94558. */
  94559. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  94560. }
  94561. }
  94562. declare module BABYLON {
  94563. /**
  94564. * Options to be used when creating an effect.
  94565. */
  94566. export class EffectCreationOptions {
  94567. /**
  94568. * Atrributes that will be used in the shader.
  94569. */
  94570. attributes: string[];
  94571. /**
  94572. * Uniform varible names that will be set in the shader.
  94573. */
  94574. uniformsNames: string[];
  94575. /**
  94576. * Uniform buffer varible names that will be set in the shader.
  94577. */
  94578. uniformBuffersNames: string[];
  94579. /**
  94580. * Sampler texture variable names that will be set in the shader.
  94581. */
  94582. samplers: string[];
  94583. /**
  94584. * Define statements that will be set in the shader.
  94585. */
  94586. defines: any;
  94587. /**
  94588. * Possible fallbacks for this effect to improve performance when needed.
  94589. */
  94590. fallbacks: Nullable<IEffectFallbacks>;
  94591. /**
  94592. * Callback that will be called when the shader is compiled.
  94593. */
  94594. onCompiled: Nullable<(effect: Effect) => void>;
  94595. /**
  94596. * Callback that will be called if an error occurs during shader compilation.
  94597. */
  94598. onError: Nullable<(effect: Effect, errors: string) => void>;
  94599. /**
  94600. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94601. */
  94602. indexParameters?: any;
  94603. /**
  94604. * Max number of lights that can be used in the shader.
  94605. */
  94606. maxSimultaneousLights?: number;
  94607. /**
  94608. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94609. */
  94610. transformFeedbackVaryings?: Nullable<string[]>;
  94611. }
  94612. /**
  94613. * Effect containing vertex and fragment shader that can be executed on an object.
  94614. */
  94615. export class Effect implements IDisposable {
  94616. /**
  94617. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94618. */
  94619. static ShadersRepository: string;
  94620. /**
  94621. * Name of the effect.
  94622. */
  94623. name: any;
  94624. /**
  94625. * String container all the define statements that should be set on the shader.
  94626. */
  94627. defines: string;
  94628. /**
  94629. * Callback that will be called when the shader is compiled.
  94630. */
  94631. onCompiled: Nullable<(effect: Effect) => void>;
  94632. /**
  94633. * Callback that will be called if an error occurs during shader compilation.
  94634. */
  94635. onError: Nullable<(effect: Effect, errors: string) => void>;
  94636. /**
  94637. * Callback that will be called when effect is bound.
  94638. */
  94639. onBind: Nullable<(effect: Effect) => void>;
  94640. /**
  94641. * Unique ID of the effect.
  94642. */
  94643. uniqueId: number;
  94644. /**
  94645. * Observable that will be called when the shader is compiled.
  94646. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  94647. */
  94648. onCompileObservable: Observable<Effect>;
  94649. /**
  94650. * Observable that will be called if an error occurs during shader compilation.
  94651. */
  94652. onErrorObservable: Observable<Effect>;
  94653. /** @hidden */
  94654. _onBindObservable: Nullable<Observable<Effect>>;
  94655. /**
  94656. * Observable that will be called when effect is bound.
  94657. */
  94658. readonly onBindObservable: Observable<Effect>;
  94659. /** @hidden */
  94660. _bonesComputationForcedToCPU: boolean;
  94661. private static _uniqueIdSeed;
  94662. private _engine;
  94663. private _uniformBuffersNames;
  94664. private _uniformsNames;
  94665. private _samplerList;
  94666. private _samplers;
  94667. private _isReady;
  94668. private _compilationError;
  94669. private _attributesNames;
  94670. private _attributes;
  94671. private _uniforms;
  94672. /**
  94673. * Key for the effect.
  94674. * @hidden
  94675. */
  94676. _key: string;
  94677. private _indexParameters;
  94678. private _fallbacks;
  94679. private _vertexSourceCode;
  94680. private _fragmentSourceCode;
  94681. private _vertexSourceCodeOverride;
  94682. private _fragmentSourceCodeOverride;
  94683. private _transformFeedbackVaryings;
  94684. /**
  94685. * Compiled shader to webGL program.
  94686. * @hidden
  94687. */
  94688. _pipelineContext: Nullable<IPipelineContext>;
  94689. private _valueCache;
  94690. private static _baseCache;
  94691. /**
  94692. * Instantiates an effect.
  94693. * An effect can be used to create/manage/execute vertex and fragment shaders.
  94694. * @param baseName Name of the effect.
  94695. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  94696. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  94697. * @param samplers List of sampler variables that will be passed to the shader.
  94698. * @param engine Engine to be used to render the effect
  94699. * @param defines Define statements to be added to the shader.
  94700. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  94701. * @param onCompiled Callback that will be called when the shader is compiled.
  94702. * @param onError Callback that will be called if an error occurs during shader compilation.
  94703. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94704. */
  94705. 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);
  94706. private _useFinalCode;
  94707. /**
  94708. * Unique key for this effect
  94709. */
  94710. readonly key: string;
  94711. /**
  94712. * If the effect has been compiled and prepared.
  94713. * @returns if the effect is compiled and prepared.
  94714. */
  94715. isReady(): boolean;
  94716. private _isReadyInternal;
  94717. /**
  94718. * The engine the effect was initialized with.
  94719. * @returns the engine.
  94720. */
  94721. getEngine(): Engine;
  94722. /**
  94723. * The pipeline context for this effect
  94724. * @returns the associated pipeline context
  94725. */
  94726. getPipelineContext(): Nullable<IPipelineContext>;
  94727. /**
  94728. * The set of names of attribute variables for the shader.
  94729. * @returns An array of attribute names.
  94730. */
  94731. getAttributesNames(): string[];
  94732. /**
  94733. * Returns the attribute at the given index.
  94734. * @param index The index of the attribute.
  94735. * @returns The location of the attribute.
  94736. */
  94737. getAttributeLocation(index: number): number;
  94738. /**
  94739. * Returns the attribute based on the name of the variable.
  94740. * @param name of the attribute to look up.
  94741. * @returns the attribute location.
  94742. */
  94743. getAttributeLocationByName(name: string): number;
  94744. /**
  94745. * The number of attributes.
  94746. * @returns the numnber of attributes.
  94747. */
  94748. getAttributesCount(): number;
  94749. /**
  94750. * Gets the index of a uniform variable.
  94751. * @param uniformName of the uniform to look up.
  94752. * @returns the index.
  94753. */
  94754. getUniformIndex(uniformName: string): number;
  94755. /**
  94756. * Returns the attribute based on the name of the variable.
  94757. * @param uniformName of the uniform to look up.
  94758. * @returns the location of the uniform.
  94759. */
  94760. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  94761. /**
  94762. * Returns an array of sampler variable names
  94763. * @returns The array of sampler variable neames.
  94764. */
  94765. getSamplers(): string[];
  94766. /**
  94767. * The error from the last compilation.
  94768. * @returns the error string.
  94769. */
  94770. getCompilationError(): string;
  94771. /**
  94772. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  94773. * @param func The callback to be used.
  94774. */
  94775. executeWhenCompiled(func: (effect: Effect) => void): void;
  94776. private _checkIsReady;
  94777. /** @hidden */
  94778. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  94779. /** @hidden */
  94780. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  94781. /** @hidden */
  94782. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  94783. /**
  94784. * Recompiles the webGL program
  94785. * @param vertexSourceCode The source code for the vertex shader.
  94786. * @param fragmentSourceCode The source code for the fragment shader.
  94787. * @param onCompiled Callback called when completed.
  94788. * @param onError Callback called on error.
  94789. * @hidden
  94790. */
  94791. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  94792. /**
  94793. * Prepares the effect
  94794. * @hidden
  94795. */
  94796. _prepareEffect(): void;
  94797. private _processCompilationErrors;
  94798. /**
  94799. * Checks if the effect is supported. (Must be called after compilation)
  94800. */
  94801. readonly isSupported: boolean;
  94802. /**
  94803. * Binds a texture to the engine to be used as output of the shader.
  94804. * @param channel Name of the output variable.
  94805. * @param texture Texture to bind.
  94806. * @hidden
  94807. */
  94808. _bindTexture(channel: string, texture: InternalTexture): void;
  94809. /**
  94810. * Sets a texture on the engine to be used in the shader.
  94811. * @param channel Name of the sampler variable.
  94812. * @param texture Texture to set.
  94813. */
  94814. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  94815. /**
  94816. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  94817. * @param channel Name of the sampler variable.
  94818. * @param texture Texture to set.
  94819. */
  94820. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  94821. /**
  94822. * Sets an array of textures on the engine to be used in the shader.
  94823. * @param channel Name of the variable.
  94824. * @param textures Textures to set.
  94825. */
  94826. setTextureArray(channel: string, textures: BaseTexture[]): void;
  94827. /**
  94828. * 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)
  94829. * @param channel Name of the sampler variable.
  94830. * @param postProcess Post process to get the input texture from.
  94831. */
  94832. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  94833. /**
  94834. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  94835. * 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)
  94836. * @param channel Name of the sampler variable.
  94837. * @param postProcess Post process to get the output texture from.
  94838. */
  94839. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  94840. /** @hidden */
  94841. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  94842. /** @hidden */
  94843. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  94844. /** @hidden */
  94845. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  94846. /** @hidden */
  94847. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  94848. /**
  94849. * Binds a buffer to a uniform.
  94850. * @param buffer Buffer to bind.
  94851. * @param name Name of the uniform variable to bind to.
  94852. */
  94853. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  94854. /**
  94855. * Binds block to a uniform.
  94856. * @param blockName Name of the block to bind.
  94857. * @param index Index to bind.
  94858. */
  94859. bindUniformBlock(blockName: string, index: number): void;
  94860. /**
  94861. * Sets an interger value on a uniform variable.
  94862. * @param uniformName Name of the variable.
  94863. * @param value Value to be set.
  94864. * @returns this effect.
  94865. */
  94866. setInt(uniformName: string, value: number): Effect;
  94867. /**
  94868. * Sets an int array on a uniform variable.
  94869. * @param uniformName Name of the variable.
  94870. * @param array array to be set.
  94871. * @returns this effect.
  94872. */
  94873. setIntArray(uniformName: string, array: Int32Array): Effect;
  94874. /**
  94875. * 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)
  94876. * @param uniformName Name of the variable.
  94877. * @param array array to be set.
  94878. * @returns this effect.
  94879. */
  94880. setIntArray2(uniformName: string, array: Int32Array): Effect;
  94881. /**
  94882. * 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)
  94883. * @param uniformName Name of the variable.
  94884. * @param array array to be set.
  94885. * @returns this effect.
  94886. */
  94887. setIntArray3(uniformName: string, array: Int32Array): Effect;
  94888. /**
  94889. * 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)
  94890. * @param uniformName Name of the variable.
  94891. * @param array array to be set.
  94892. * @returns this effect.
  94893. */
  94894. setIntArray4(uniformName: string, array: Int32Array): Effect;
  94895. /**
  94896. * Sets an float array on a uniform variable.
  94897. * @param uniformName Name of the variable.
  94898. * @param array array to be set.
  94899. * @returns this effect.
  94900. */
  94901. setFloatArray(uniformName: string, array: Float32Array): Effect;
  94902. /**
  94903. * 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)
  94904. * @param uniformName Name of the variable.
  94905. * @param array array to be set.
  94906. * @returns this effect.
  94907. */
  94908. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  94909. /**
  94910. * 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)
  94911. * @param uniformName Name of the variable.
  94912. * @param array array to be set.
  94913. * @returns this effect.
  94914. */
  94915. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  94916. /**
  94917. * 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)
  94918. * @param uniformName Name of the variable.
  94919. * @param array array to be set.
  94920. * @returns this effect.
  94921. */
  94922. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  94923. /**
  94924. * Sets an array on a uniform variable.
  94925. * @param uniformName Name of the variable.
  94926. * @param array array to be set.
  94927. * @returns this effect.
  94928. */
  94929. setArray(uniformName: string, array: number[]): Effect;
  94930. /**
  94931. * 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)
  94932. * @param uniformName Name of the variable.
  94933. * @param array array to be set.
  94934. * @returns this effect.
  94935. */
  94936. setArray2(uniformName: string, array: number[]): Effect;
  94937. /**
  94938. * 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)
  94939. * @param uniformName Name of the variable.
  94940. * @param array array to be set.
  94941. * @returns this effect.
  94942. */
  94943. setArray3(uniformName: string, array: number[]): Effect;
  94944. /**
  94945. * 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)
  94946. * @param uniformName Name of the variable.
  94947. * @param array array to be set.
  94948. * @returns this effect.
  94949. */
  94950. setArray4(uniformName: string, array: number[]): Effect;
  94951. /**
  94952. * Sets matrices on a uniform variable.
  94953. * @param uniformName Name of the variable.
  94954. * @param matrices matrices to be set.
  94955. * @returns this effect.
  94956. */
  94957. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  94958. /**
  94959. * Sets matrix on a uniform variable.
  94960. * @param uniformName Name of the variable.
  94961. * @param matrix matrix to be set.
  94962. * @returns this effect.
  94963. */
  94964. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  94965. /**
  94966. * 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)
  94967. * @param uniformName Name of the variable.
  94968. * @param matrix matrix to be set.
  94969. * @returns this effect.
  94970. */
  94971. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  94972. /**
  94973. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  94974. * @param uniformName Name of the variable.
  94975. * @param matrix matrix to be set.
  94976. * @returns this effect.
  94977. */
  94978. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  94979. /**
  94980. * Sets a float on a uniform variable.
  94981. * @param uniformName Name of the variable.
  94982. * @param value value to be set.
  94983. * @returns this effect.
  94984. */
  94985. setFloat(uniformName: string, value: number): Effect;
  94986. /**
  94987. * Sets a boolean on a uniform variable.
  94988. * @param uniformName Name of the variable.
  94989. * @param bool value to be set.
  94990. * @returns this effect.
  94991. */
  94992. setBool(uniformName: string, bool: boolean): Effect;
  94993. /**
  94994. * Sets a Vector2 on a uniform variable.
  94995. * @param uniformName Name of the variable.
  94996. * @param vector2 vector2 to be set.
  94997. * @returns this effect.
  94998. */
  94999. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  95000. /**
  95001. * Sets a float2 on a uniform variable.
  95002. * @param uniformName Name of the variable.
  95003. * @param x First float in float2.
  95004. * @param y Second float in float2.
  95005. * @returns this effect.
  95006. */
  95007. setFloat2(uniformName: string, x: number, y: number): Effect;
  95008. /**
  95009. * Sets a Vector3 on a uniform variable.
  95010. * @param uniformName Name of the variable.
  95011. * @param vector3 Value to be set.
  95012. * @returns this effect.
  95013. */
  95014. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  95015. /**
  95016. * Sets a float3 on a uniform variable.
  95017. * @param uniformName Name of the variable.
  95018. * @param x First float in float3.
  95019. * @param y Second float in float3.
  95020. * @param z Third float in float3.
  95021. * @returns this effect.
  95022. */
  95023. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  95024. /**
  95025. * Sets a Vector4 on a uniform variable.
  95026. * @param uniformName Name of the variable.
  95027. * @param vector4 Value to be set.
  95028. * @returns this effect.
  95029. */
  95030. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  95031. /**
  95032. * Sets a float4 on a uniform variable.
  95033. * @param uniformName Name of the variable.
  95034. * @param x First float in float4.
  95035. * @param y Second float in float4.
  95036. * @param z Third float in float4.
  95037. * @param w Fourth float in float4.
  95038. * @returns this effect.
  95039. */
  95040. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  95041. /**
  95042. * Sets a Color3 on a uniform variable.
  95043. * @param uniformName Name of the variable.
  95044. * @param color3 Value to be set.
  95045. * @returns this effect.
  95046. */
  95047. setColor3(uniformName: string, color3: IColor3Like): Effect;
  95048. /**
  95049. * Sets a Color4 on a uniform variable.
  95050. * @param uniformName Name of the variable.
  95051. * @param color3 Value to be set.
  95052. * @param alpha Alpha value to be set.
  95053. * @returns this effect.
  95054. */
  95055. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  95056. /**
  95057. * Sets a Color4 on a uniform variable
  95058. * @param uniformName defines the name of the variable
  95059. * @param color4 defines the value to be set
  95060. * @returns this effect.
  95061. */
  95062. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  95063. /** Release all associated resources */
  95064. dispose(): void;
  95065. /**
  95066. * This function will add a new shader to the shader store
  95067. * @param name the name of the shader
  95068. * @param pixelShader optional pixel shader content
  95069. * @param vertexShader optional vertex shader content
  95070. */
  95071. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  95072. /**
  95073. * Store of each shader (The can be looked up using effect.key)
  95074. */
  95075. static ShadersStore: {
  95076. [key: string]: string;
  95077. };
  95078. /**
  95079. * Store of each included file for a shader (The can be looked up using effect.key)
  95080. */
  95081. static IncludesShadersStore: {
  95082. [key: string]: string;
  95083. };
  95084. /**
  95085. * Resets the cache of effects.
  95086. */
  95087. static ResetCache(): void;
  95088. }
  95089. }
  95090. declare module BABYLON {
  95091. /**
  95092. * Class used to describe the capabilities of the engine relatively to the current browser
  95093. */
  95094. export class EngineCapabilities {
  95095. /** Maximum textures units per fragment shader */
  95096. maxTexturesImageUnits: number;
  95097. /** Maximum texture units per vertex shader */
  95098. maxVertexTextureImageUnits: number;
  95099. /** Maximum textures units in the entire pipeline */
  95100. maxCombinedTexturesImageUnits: number;
  95101. /** Maximum texture size */
  95102. maxTextureSize: number;
  95103. /** Maximum cube texture size */
  95104. maxCubemapTextureSize: number;
  95105. /** Maximum render texture size */
  95106. maxRenderTextureSize: number;
  95107. /** Maximum number of vertex attributes */
  95108. maxVertexAttribs: number;
  95109. /** Maximum number of varyings */
  95110. maxVaryingVectors: number;
  95111. /** Maximum number of uniforms per vertex shader */
  95112. maxVertexUniformVectors: number;
  95113. /** Maximum number of uniforms per fragment shader */
  95114. maxFragmentUniformVectors: number;
  95115. /** Defines if standard derivates (dx/dy) are supported */
  95116. standardDerivatives: boolean;
  95117. /** Defines if s3tc texture compression is supported */
  95118. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95119. /** Defines if pvrtc texture compression is supported */
  95120. pvrtc: any;
  95121. /** Defines if etc1 texture compression is supported */
  95122. etc1: any;
  95123. /** Defines if etc2 texture compression is supported */
  95124. etc2: any;
  95125. /** Defines if astc texture compression is supported */
  95126. astc: any;
  95127. /** Defines if float textures are supported */
  95128. textureFloat: boolean;
  95129. /** Defines if vertex array objects are supported */
  95130. vertexArrayObject: boolean;
  95131. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95132. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95133. /** Gets the maximum level of anisotropy supported */
  95134. maxAnisotropy: number;
  95135. /** Defines if instancing is supported */
  95136. instancedArrays: boolean;
  95137. /** Defines if 32 bits indices are supported */
  95138. uintIndices: boolean;
  95139. /** Defines if high precision shaders are supported */
  95140. highPrecisionShaderSupported: boolean;
  95141. /** Defines if depth reading in the fragment shader is supported */
  95142. fragmentDepthSupported: boolean;
  95143. /** Defines if float texture linear filtering is supported*/
  95144. textureFloatLinearFiltering: boolean;
  95145. /** Defines if rendering to float textures is supported */
  95146. textureFloatRender: boolean;
  95147. /** Defines if half float textures are supported*/
  95148. textureHalfFloat: boolean;
  95149. /** Defines if half float texture linear filtering is supported*/
  95150. textureHalfFloatLinearFiltering: boolean;
  95151. /** Defines if rendering to half float textures is supported */
  95152. textureHalfFloatRender: boolean;
  95153. /** Defines if textureLOD shader command is supported */
  95154. textureLOD: boolean;
  95155. /** Defines if draw buffers extension is supported */
  95156. drawBuffersExtension: boolean;
  95157. /** Defines if depth textures are supported */
  95158. depthTextureExtension: boolean;
  95159. /** Defines if float color buffer are supported */
  95160. colorBufferFloat: boolean;
  95161. /** Gets disjoint timer query extension (null if not supported) */
  95162. timerQuery: EXT_disjoint_timer_query;
  95163. /** Defines if timestamp can be used with timer query */
  95164. canUseTimestampForTimerQuery: boolean;
  95165. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95166. multiview: any;
  95167. /** Function used to let the system compiles shaders in background */
  95168. parallelShaderCompile: {
  95169. COMPLETION_STATUS_KHR: number;
  95170. };
  95171. /** Max number of texture samples for MSAA */
  95172. maxMSAASamples: number;
  95173. /** Defines if the blend min max extension is supported */
  95174. blendMinMax: boolean;
  95175. }
  95176. }
  95177. declare module BABYLON {
  95178. /**
  95179. * This class is used to track a performance counter which is number based.
  95180. * The user has access to many properties which give statistics of different nature.
  95181. *
  95182. * The implementer can track two kinds of Performance Counter: time and count.
  95183. * 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.
  95184. * 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.
  95185. */
  95186. export class PerfCounter {
  95187. /**
  95188. * Gets or sets a global boolean to turn on and off all the counters
  95189. */
  95190. static Enabled: boolean;
  95191. /**
  95192. * Returns the smallest value ever
  95193. */
  95194. readonly min: number;
  95195. /**
  95196. * Returns the biggest value ever
  95197. */
  95198. readonly max: number;
  95199. /**
  95200. * Returns the average value since the performance counter is running
  95201. */
  95202. readonly average: number;
  95203. /**
  95204. * Returns the average value of the last second the counter was monitored
  95205. */
  95206. readonly lastSecAverage: number;
  95207. /**
  95208. * Returns the current value
  95209. */
  95210. readonly current: number;
  95211. /**
  95212. * Gets the accumulated total
  95213. */
  95214. readonly total: number;
  95215. /**
  95216. * Gets the total value count
  95217. */
  95218. readonly count: number;
  95219. /**
  95220. * Creates a new counter
  95221. */
  95222. constructor();
  95223. /**
  95224. * Call this method to start monitoring a new frame.
  95225. * 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.
  95226. */
  95227. fetchNewFrame(): void;
  95228. /**
  95229. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  95230. * @param newCount the count value to add to the monitored count
  95231. * @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.
  95232. */
  95233. addCount(newCount: number, fetchResult: boolean): void;
  95234. /**
  95235. * Start monitoring this performance counter
  95236. */
  95237. beginMonitoring(): void;
  95238. /**
  95239. * Compute the time lapsed since the previous beginMonitoring() call.
  95240. * @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
  95241. */
  95242. endMonitoring(newFrame?: boolean): void;
  95243. private _fetchResult;
  95244. private _startMonitoringTime;
  95245. private _min;
  95246. private _max;
  95247. private _average;
  95248. private _current;
  95249. private _totalValueCount;
  95250. private _totalAccumulated;
  95251. private _lastSecAverage;
  95252. private _lastSecAccumulated;
  95253. private _lastSecTime;
  95254. private _lastSecValueCount;
  95255. }
  95256. }
  95257. declare module BABYLON {
  95258. /**
  95259. * @hidden
  95260. **/
  95261. export class DepthCullingState {
  95262. private _isDepthTestDirty;
  95263. private _isDepthMaskDirty;
  95264. private _isDepthFuncDirty;
  95265. private _isCullFaceDirty;
  95266. private _isCullDirty;
  95267. private _isZOffsetDirty;
  95268. private _isFrontFaceDirty;
  95269. private _depthTest;
  95270. private _depthMask;
  95271. private _depthFunc;
  95272. private _cull;
  95273. private _cullFace;
  95274. private _zOffset;
  95275. private _frontFace;
  95276. /**
  95277. * Initializes the state.
  95278. */
  95279. constructor();
  95280. readonly isDirty: boolean;
  95281. zOffset: number;
  95282. cullFace: Nullable<number>;
  95283. cull: Nullable<boolean>;
  95284. depthFunc: Nullable<number>;
  95285. depthMask: boolean;
  95286. depthTest: boolean;
  95287. frontFace: Nullable<number>;
  95288. reset(): void;
  95289. apply(gl: WebGLRenderingContext): void;
  95290. }
  95291. }
  95292. declare module BABYLON {
  95293. /**
  95294. * @hidden
  95295. **/
  95296. export class StencilState {
  95297. /** 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 */
  95298. static readonly ALWAYS: number;
  95299. /** Passed to stencilOperation to specify that stencil value must be kept */
  95300. static readonly KEEP: number;
  95301. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95302. static readonly REPLACE: number;
  95303. private _isStencilTestDirty;
  95304. private _isStencilMaskDirty;
  95305. private _isStencilFuncDirty;
  95306. private _isStencilOpDirty;
  95307. private _stencilTest;
  95308. private _stencilMask;
  95309. private _stencilFunc;
  95310. private _stencilFuncRef;
  95311. private _stencilFuncMask;
  95312. private _stencilOpStencilFail;
  95313. private _stencilOpDepthFail;
  95314. private _stencilOpStencilDepthPass;
  95315. readonly isDirty: boolean;
  95316. stencilFunc: number;
  95317. stencilFuncRef: number;
  95318. stencilFuncMask: number;
  95319. stencilOpStencilFail: number;
  95320. stencilOpDepthFail: number;
  95321. stencilOpStencilDepthPass: number;
  95322. stencilMask: number;
  95323. stencilTest: boolean;
  95324. constructor();
  95325. reset(): void;
  95326. apply(gl: WebGLRenderingContext): void;
  95327. }
  95328. }
  95329. declare module BABYLON {
  95330. /**
  95331. * @hidden
  95332. **/
  95333. export class AlphaState {
  95334. private _isAlphaBlendDirty;
  95335. private _isBlendFunctionParametersDirty;
  95336. private _isBlendEquationParametersDirty;
  95337. private _isBlendConstantsDirty;
  95338. private _alphaBlend;
  95339. private _blendFunctionParameters;
  95340. private _blendEquationParameters;
  95341. private _blendConstants;
  95342. /**
  95343. * Initializes the state.
  95344. */
  95345. constructor();
  95346. readonly isDirty: boolean;
  95347. alphaBlend: boolean;
  95348. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  95349. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  95350. setAlphaEquationParameters(rgb: number, alpha: number): void;
  95351. reset(): void;
  95352. apply(gl: WebGLRenderingContext): void;
  95353. }
  95354. }
  95355. declare module BABYLON {
  95356. /** @hidden */
  95357. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95358. attributeProcessor(attribute: string): string;
  95359. varyingProcessor(varying: string, isFragment: boolean): string;
  95360. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95361. }
  95362. }
  95363. declare module BABYLON {
  95364. /**
  95365. * Interface for attribute information associated with buffer instanciation
  95366. */
  95367. export class InstancingAttributeInfo {
  95368. /**
  95369. * Index/offset of the attribute in the vertex shader
  95370. */
  95371. index: number;
  95372. /**
  95373. * size of the attribute, 1, 2, 3 or 4
  95374. */
  95375. attributeSize: number;
  95376. /**
  95377. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95378. * default is FLOAT
  95379. */
  95380. attribyteType: number;
  95381. /**
  95382. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95383. */
  95384. normalized: boolean;
  95385. /**
  95386. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95387. */
  95388. offset: number;
  95389. /**
  95390. * Name of the GLSL attribute, for debugging purpose only
  95391. */
  95392. attributeName: string;
  95393. }
  95394. }
  95395. declare module BABYLON {
  95396. interface ThinEngine {
  95397. /**
  95398. * Update a video texture
  95399. * @param texture defines the texture to update
  95400. * @param video defines the video element to use
  95401. * @param invertY defines if data must be stored with Y axis inverted
  95402. */
  95403. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95404. }
  95405. }
  95406. declare module BABYLON {
  95407. /**
  95408. * Settings for finer control over video usage
  95409. */
  95410. export interface VideoTextureSettings {
  95411. /**
  95412. * Applies `autoplay` to video, if specified
  95413. */
  95414. autoPlay?: boolean;
  95415. /**
  95416. * Applies `loop` to video, if specified
  95417. */
  95418. loop?: boolean;
  95419. /**
  95420. * Automatically updates internal texture from video at every frame in the render loop
  95421. */
  95422. autoUpdateTexture: boolean;
  95423. /**
  95424. * Image src displayed during the video loading or until the user interacts with the video.
  95425. */
  95426. poster?: string;
  95427. }
  95428. /**
  95429. * If you want to display a video in your scene, this is the special texture for that.
  95430. * This special texture works similar to other textures, with the exception of a few parameters.
  95431. * @see https://doc.babylonjs.com/how_to/video_texture
  95432. */
  95433. export class VideoTexture extends Texture {
  95434. /**
  95435. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95436. */
  95437. readonly autoUpdateTexture: boolean;
  95438. /**
  95439. * The video instance used by the texture internally
  95440. */
  95441. readonly video: HTMLVideoElement;
  95442. private _onUserActionRequestedObservable;
  95443. /**
  95444. * Event triggerd when a dom action is required by the user to play the video.
  95445. * This happens due to recent changes in browser policies preventing video to auto start.
  95446. */
  95447. readonly onUserActionRequestedObservable: Observable<Texture>;
  95448. private _generateMipMaps;
  95449. private _engine;
  95450. private _stillImageCaptured;
  95451. private _displayingPosterTexture;
  95452. private _settings;
  95453. private _createInternalTextureOnEvent;
  95454. private _frameId;
  95455. /**
  95456. * Creates a video texture.
  95457. * If you want to display a video in your scene, this is the special texture for that.
  95458. * This special texture works similar to other textures, with the exception of a few parameters.
  95459. * @see https://doc.babylonjs.com/how_to/video_texture
  95460. * @param name optional name, will detect from video source, if not defined
  95461. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95462. * @param scene is obviously the current scene.
  95463. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95464. * @param invertY is false by default but can be used to invert video on Y axis
  95465. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95466. * @param settings allows finer control over video usage
  95467. */
  95468. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95469. private _getName;
  95470. private _getVideo;
  95471. private _createInternalTexture;
  95472. private reset;
  95473. /**
  95474. * @hidden Internal method to initiate `update`.
  95475. */
  95476. _rebuild(): void;
  95477. /**
  95478. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95479. */
  95480. update(): void;
  95481. /**
  95482. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95483. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95484. */
  95485. updateTexture(isVisible: boolean): void;
  95486. protected _updateInternalTexture: () => void;
  95487. /**
  95488. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95489. * @param url New url.
  95490. */
  95491. updateURL(url: string): void;
  95492. /**
  95493. * Dispose the texture and release its associated resources.
  95494. */
  95495. dispose(): void;
  95496. /**
  95497. * Creates a video texture straight from a stream.
  95498. * @param scene Define the scene the texture should be created in
  95499. * @param stream Define the stream the texture should be created from
  95500. * @returns The created video texture as a promise
  95501. */
  95502. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95503. /**
  95504. * Creates a video texture straight from your WebCam video feed.
  95505. * @param scene Define the scene the texture should be created in
  95506. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95507. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95508. * @returns The created video texture as a promise
  95509. */
  95510. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95511. minWidth: number;
  95512. maxWidth: number;
  95513. minHeight: number;
  95514. maxHeight: number;
  95515. deviceId: string;
  95516. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): 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 onReady Define a callback to triggered once the texture will be ready
  95521. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95522. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95523. */
  95524. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95525. minWidth: number;
  95526. maxWidth: number;
  95527. minHeight: number;
  95528. maxHeight: number;
  95529. deviceId: string;
  95530. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95531. }
  95532. }
  95533. declare module BABYLON {
  95534. /**
  95535. * Defines the interface used by objects working like Scene
  95536. * @hidden
  95537. */
  95538. interface ISceneLike {
  95539. _addPendingData(data: any): void;
  95540. _removePendingData(data: any): void;
  95541. offlineProvider: IOfflineProvider;
  95542. }
  95543. /** Interface defining initialization parameters for Engine class */
  95544. export interface EngineOptions extends WebGLContextAttributes {
  95545. /**
  95546. * Defines if the engine should no exceed a specified device ratio
  95547. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95548. */
  95549. limitDeviceRatio?: number;
  95550. /**
  95551. * Defines if webvr should be enabled automatically
  95552. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95553. */
  95554. autoEnableWebVR?: boolean;
  95555. /**
  95556. * Defines if webgl2 should be turned off even if supported
  95557. * @see http://doc.babylonjs.com/features/webgl2
  95558. */
  95559. disableWebGL2Support?: boolean;
  95560. /**
  95561. * Defines if webaudio should be initialized as well
  95562. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95563. */
  95564. audioEngine?: boolean;
  95565. /**
  95566. * Defines if animations should run using a deterministic lock step
  95567. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95568. */
  95569. deterministicLockstep?: boolean;
  95570. /** Defines the maximum steps to use with deterministic lock step mode */
  95571. lockstepMaxSteps?: number;
  95572. /**
  95573. * Defines that engine should ignore context lost events
  95574. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95575. */
  95576. doNotHandleContextLost?: boolean;
  95577. /**
  95578. * Defines that engine should ignore modifying touch action attribute and style
  95579. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95580. */
  95581. doNotHandleTouchAction?: boolean;
  95582. /**
  95583. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95584. */
  95585. useHighPrecisionFloats?: boolean;
  95586. }
  95587. /**
  95588. * The base engine class (root of all engines)
  95589. */
  95590. export class ThinEngine {
  95591. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95592. static ExceptionList: ({
  95593. key: string;
  95594. capture: string;
  95595. captureConstraint: number;
  95596. targets: string[];
  95597. } | {
  95598. key: string;
  95599. capture: null;
  95600. captureConstraint: null;
  95601. targets: string[];
  95602. })[];
  95603. /** @hidden */
  95604. static _TextureLoaders: IInternalTextureLoader[];
  95605. /**
  95606. * Returns the current npm package of the sdk
  95607. */
  95608. static readonly NpmPackage: string;
  95609. /**
  95610. * Returns the current version of the framework
  95611. */
  95612. static readonly Version: string;
  95613. /**
  95614. * Returns a string describing the current engine
  95615. */
  95616. readonly description: string;
  95617. /**
  95618. * Gets or sets the epsilon value used by collision engine
  95619. */
  95620. static CollisionsEpsilon: number;
  95621. /**
  95622. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95623. */
  95624. static ShadersRepository: string;
  95625. /** @hidden */
  95626. _shaderProcessor: IShaderProcessor;
  95627. /**
  95628. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95629. */
  95630. forcePOTTextures: boolean;
  95631. /**
  95632. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95633. */
  95634. isFullscreen: boolean;
  95635. /**
  95636. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95637. */
  95638. cullBackFaces: boolean;
  95639. /**
  95640. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95641. */
  95642. renderEvenInBackground: boolean;
  95643. /**
  95644. * Gets or sets a boolean indicating that cache can be kept between frames
  95645. */
  95646. preventCacheWipeBetweenFrames: boolean;
  95647. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95648. validateShaderPrograms: boolean;
  95649. /**
  95650. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95651. */
  95652. disableUniformBuffers: boolean;
  95653. /** @hidden */
  95654. _uniformBuffers: UniformBuffer[];
  95655. /**
  95656. * Gets a boolean indicating that the engine supports uniform buffers
  95657. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95658. */
  95659. readonly supportsUniformBuffers: boolean;
  95660. /** @hidden */
  95661. _gl: WebGLRenderingContext;
  95662. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  95663. protected _windowIsBackground: boolean;
  95664. protected _webGLVersion: number;
  95665. protected _highPrecisionShadersAllowed: boolean;
  95666. /** @hidden */
  95667. readonly _shouldUseHighPrecisionShader: boolean;
  95668. /**
  95669. * Gets a boolean indicating that only power of 2 textures are supported
  95670. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  95671. */
  95672. readonly needPOTTextures: boolean;
  95673. /** @hidden */
  95674. _badOS: boolean;
  95675. /** @hidden */
  95676. _badDesktopOS: boolean;
  95677. private _hardwareScalingLevel;
  95678. /** @hidden */
  95679. _caps: EngineCapabilities;
  95680. private _isStencilEnable;
  95681. protected _colorWrite: boolean;
  95682. /** @hidden */
  95683. _drawCalls: PerfCounter;
  95684. private _glVersion;
  95685. private _glRenderer;
  95686. private _glVendor;
  95687. /** @hidden */
  95688. _videoTextureSupported: boolean;
  95689. protected _renderingQueueLaunched: boolean;
  95690. protected _activeRenderLoops: (() => void)[];
  95691. /**
  95692. * Observable signaled when a context lost event is raised
  95693. */
  95694. onContextLostObservable: Observable<ThinEngine>;
  95695. /**
  95696. * Observable signaled when a context restored event is raised
  95697. */
  95698. onContextRestoredObservable: Observable<ThinEngine>;
  95699. private _onContextLost;
  95700. private _onContextRestored;
  95701. protected _contextWasLost: boolean;
  95702. /** @hidden */
  95703. _doNotHandleContextLost: boolean;
  95704. /**
  95705. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  95706. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  95707. */
  95708. doNotHandleContextLost: boolean;
  95709. /**
  95710. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  95711. */
  95712. disableVertexArrayObjects: boolean;
  95713. /** @hidden */
  95714. protected _depthCullingState: DepthCullingState;
  95715. /** @hidden */
  95716. protected _stencilState: StencilState;
  95717. /** @hidden */
  95718. protected _alphaState: AlphaState;
  95719. /** @hidden */
  95720. _internalTexturesCache: InternalTexture[];
  95721. /** @hidden */
  95722. protected _activeChannel: number;
  95723. private _currentTextureChannel;
  95724. /** @hidden */
  95725. protected _boundTexturesCache: {
  95726. [key: string]: Nullable<InternalTexture>;
  95727. };
  95728. /** @hidden */
  95729. protected _currentEffect: Nullable<Effect>;
  95730. /** @hidden */
  95731. protected _currentProgram: Nullable<WebGLProgram>;
  95732. private _compiledEffects;
  95733. private _vertexAttribArraysEnabled;
  95734. /** @hidden */
  95735. protected _cachedViewport: Nullable<IViewportLike>;
  95736. private _cachedVertexArrayObject;
  95737. /** @hidden */
  95738. protected _cachedVertexBuffers: any;
  95739. /** @hidden */
  95740. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  95741. /** @hidden */
  95742. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  95743. /** @hidden */
  95744. _currentRenderTarget: Nullable<InternalTexture>;
  95745. private _uintIndicesCurrentlySet;
  95746. private _currentBoundBuffer;
  95747. /** @hidden */
  95748. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  95749. private _currentBufferPointers;
  95750. private _currentInstanceLocations;
  95751. private _currentInstanceBuffers;
  95752. private _textureUnits;
  95753. /** @hidden */
  95754. _workingCanvas: Nullable<HTMLCanvasElement>;
  95755. /** @hidden */
  95756. _workingContext: Nullable<CanvasRenderingContext2D>;
  95757. /** @hidden */
  95758. _bindedRenderFunction: any;
  95759. private _vaoRecordInProgress;
  95760. private _mustWipeVertexAttributes;
  95761. private _emptyTexture;
  95762. private _emptyCubeTexture;
  95763. private _emptyTexture3D;
  95764. /** @hidden */
  95765. _frameHandler: number;
  95766. private _nextFreeTextureSlots;
  95767. private _maxSimultaneousTextures;
  95768. private _activeRequests;
  95769. protected _texturesSupported: string[];
  95770. /** @hidden */
  95771. _textureFormatInUse: Nullable<string>;
  95772. protected readonly _supportsHardwareTextureRescaling: boolean;
  95773. /**
  95774. * Gets the list of texture formats supported
  95775. */
  95776. readonly texturesSupported: Array<string>;
  95777. /**
  95778. * Gets the list of texture formats in use
  95779. */
  95780. readonly textureFormatInUse: Nullable<string>;
  95781. /**
  95782. * Gets the current viewport
  95783. */
  95784. readonly currentViewport: Nullable<IViewportLike>;
  95785. /**
  95786. * Gets the default empty texture
  95787. */
  95788. readonly emptyTexture: InternalTexture;
  95789. /**
  95790. * Gets the default empty 3D texture
  95791. */
  95792. readonly emptyTexture3D: InternalTexture;
  95793. /**
  95794. * Gets the default empty cube texture
  95795. */
  95796. readonly emptyCubeTexture: InternalTexture;
  95797. /**
  95798. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  95799. */
  95800. readonly premultipliedAlpha: boolean;
  95801. /**
  95802. * Creates a new engine
  95803. * @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
  95804. * @param antialias defines enable antialiasing (default: false)
  95805. * @param options defines further options to be sent to the getContext() function
  95806. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  95807. */
  95808. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  95809. private _rebuildInternalTextures;
  95810. private _rebuildEffects;
  95811. /**
  95812. * Gets a boolean indicating if all created effects are ready
  95813. * @returns true if all effects are ready
  95814. */
  95815. areAllEffectsReady(): boolean;
  95816. protected _rebuildBuffers(): void;
  95817. private _initGLContext;
  95818. /**
  95819. * Gets version of the current webGL context
  95820. */
  95821. readonly webGLVersion: number;
  95822. /**
  95823. * Gets a string idenfifying the name of the class
  95824. * @returns "Engine" string
  95825. */
  95826. getClassName(): string;
  95827. /**
  95828. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  95829. */
  95830. readonly isStencilEnable: boolean;
  95831. /** @hidden */
  95832. _prepareWorkingCanvas(): void;
  95833. /**
  95834. * Reset the texture cache to empty state
  95835. */
  95836. resetTextureCache(): void;
  95837. /**
  95838. * Gets an object containing information about the current webGL context
  95839. * @returns an object containing the vender, the renderer and the version of the current webGL context
  95840. */
  95841. getGlInfo(): {
  95842. vendor: string;
  95843. renderer: string;
  95844. version: string;
  95845. };
  95846. /**
  95847. * Defines the hardware scaling level.
  95848. * By default the hardware scaling level is computed from the window device ratio.
  95849. * 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.
  95850. * @param level defines the level to use
  95851. */
  95852. setHardwareScalingLevel(level: number): void;
  95853. /**
  95854. * Gets the current hardware scaling level.
  95855. * By default the hardware scaling level is computed from the window device ratio.
  95856. * 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.
  95857. * @returns a number indicating the current hardware scaling level
  95858. */
  95859. getHardwareScalingLevel(): number;
  95860. /**
  95861. * Gets the list of loaded textures
  95862. * @returns an array containing all loaded textures
  95863. */
  95864. getLoadedTexturesCache(): InternalTexture[];
  95865. /**
  95866. * Gets the object containing all engine capabilities
  95867. * @returns the EngineCapabilities object
  95868. */
  95869. getCaps(): EngineCapabilities;
  95870. /**
  95871. * stop executing a render loop function and remove it from the execution array
  95872. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  95873. */
  95874. stopRenderLoop(renderFunction?: () => void): void;
  95875. /** @hidden */
  95876. _renderLoop(): void;
  95877. /**
  95878. * Gets the HTML canvas attached with the current webGL context
  95879. * @returns a HTML canvas
  95880. */
  95881. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  95882. /**
  95883. * Gets host window
  95884. * @returns the host window object
  95885. */
  95886. getHostWindow(): Window;
  95887. /**
  95888. * Gets the current render width
  95889. * @param useScreen defines if screen size must be used (or the current render target if any)
  95890. * @returns a number defining the current render width
  95891. */
  95892. getRenderWidth(useScreen?: boolean): number;
  95893. /**
  95894. * Gets the current render height
  95895. * @param useScreen defines if screen size must be used (or the current render target if any)
  95896. * @returns a number defining the current render height
  95897. */
  95898. getRenderHeight(useScreen?: boolean): number;
  95899. /**
  95900. * Can be used to override the current requestAnimationFrame requester.
  95901. * @hidden
  95902. */
  95903. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  95904. /**
  95905. * Register and execute a render loop. The engine can have more than one render function
  95906. * @param renderFunction defines the function to continuously execute
  95907. */
  95908. runRenderLoop(renderFunction: () => void): void;
  95909. /**
  95910. * Clear the current render buffer or the current render target (if any is set up)
  95911. * @param color defines the color to use
  95912. * @param backBuffer defines if the back buffer must be cleared
  95913. * @param depth defines if the depth buffer must be cleared
  95914. * @param stencil defines if the stencil buffer must be cleared
  95915. */
  95916. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  95917. private _viewportCached;
  95918. /** @hidden */
  95919. _viewport(x: number, y: number, width: number, height: number): void;
  95920. /**
  95921. * Set the WebGL's viewport
  95922. * @param viewport defines the viewport element to be used
  95923. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  95924. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  95925. */
  95926. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  95927. /**
  95928. * Begin a new frame
  95929. */
  95930. beginFrame(): void;
  95931. /**
  95932. * Enf the current frame
  95933. */
  95934. endFrame(): void;
  95935. /**
  95936. * Resize the view according to the canvas' size
  95937. */
  95938. resize(): void;
  95939. /**
  95940. * Force a specific size of the canvas
  95941. * @param width defines the new canvas' width
  95942. * @param height defines the new canvas' height
  95943. */
  95944. setSize(width: number, height: number): void;
  95945. /**
  95946. * Binds the frame buffer to the specified texture.
  95947. * @param texture The texture to render to or null for the default canvas
  95948. * @param faceIndex The face of the texture to render to in case of cube texture
  95949. * @param requiredWidth The width of the target to render to
  95950. * @param requiredHeight The height of the target to render to
  95951. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  95952. * @param depthStencilTexture The depth stencil texture to use to render
  95953. * @param lodLevel defines le lod level to bind to the frame buffer
  95954. */
  95955. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  95956. /** @hidden */
  95957. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  95958. /**
  95959. * Unbind the current render target texture from the webGL context
  95960. * @param texture defines the render target texture to unbind
  95961. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  95962. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  95963. */
  95964. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  95965. /**
  95966. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  95967. */
  95968. flushFramebuffer(): void;
  95969. /**
  95970. * Unbind the current render target and bind the default framebuffer
  95971. */
  95972. restoreDefaultFramebuffer(): void;
  95973. private _resetVertexBufferBinding;
  95974. /**
  95975. * Creates a vertex buffer
  95976. * @param data the data for the vertex buffer
  95977. * @returns the new WebGL static buffer
  95978. */
  95979. createVertexBuffer(data: DataArray): DataBuffer;
  95980. private _createVertexBuffer;
  95981. /**
  95982. * Creates a dynamic vertex buffer
  95983. * @param data the data for the dynamic vertex buffer
  95984. * @returns the new WebGL dynamic buffer
  95985. */
  95986. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  95987. /**
  95988. * Update a dynamic index buffer
  95989. * @param indexBuffer defines the target index buffer
  95990. * @param indices defines the data to update
  95991. * @param offset defines the offset in the target index buffer where update should start
  95992. */
  95993. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  95994. /**
  95995. * Updates a dynamic vertex buffer.
  95996. * @param vertexBuffer the vertex buffer to update
  95997. * @param data the data used to update the vertex buffer
  95998. * @param byteOffset the byte offset of the data
  95999. * @param byteLength the byte length of the data
  96000. */
  96001. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96002. private _resetIndexBufferBinding;
  96003. /**
  96004. * Creates a new index buffer
  96005. * @param indices defines the content of the index buffer
  96006. * @param updatable defines if the index buffer must be updatable
  96007. * @returns a new webGL buffer
  96008. */
  96009. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96010. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96011. /**
  96012. * Bind a webGL buffer to the webGL context
  96013. * @param buffer defines the buffer to bind
  96014. */
  96015. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96016. private bindIndexBuffer;
  96017. private bindBuffer;
  96018. /**
  96019. * update the bound buffer with the given data
  96020. * @param data defines the data to update
  96021. */
  96022. updateArrayBuffer(data: Float32Array): void;
  96023. private _vertexAttribPointer;
  96024. private _bindIndexBufferWithCache;
  96025. private _bindVertexBuffersAttributes;
  96026. /**
  96027. * Records a vertex array object
  96028. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96029. * @param vertexBuffers defines the list of vertex buffers to store
  96030. * @param indexBuffer defines the index buffer to store
  96031. * @param effect defines the effect to store
  96032. * @returns the new vertex array object
  96033. */
  96034. recordVertexArrayObject(vertexBuffers: {
  96035. [key: string]: VertexBuffer;
  96036. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96037. /**
  96038. * Bind a specific vertex array object
  96039. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96040. * @param vertexArrayObject defines the vertex array object to bind
  96041. * @param indexBuffer defines the index buffer to bind
  96042. */
  96043. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96044. /**
  96045. * Bind webGl buffers directly to the webGL context
  96046. * @param vertexBuffer defines the vertex buffer to bind
  96047. * @param indexBuffer defines the index buffer to bind
  96048. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96049. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96050. * @param effect defines the effect associated with the vertex buffer
  96051. */
  96052. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96053. private _unbindVertexArrayObject;
  96054. /**
  96055. * Bind a list of vertex buffers to the webGL context
  96056. * @param vertexBuffers defines the list of vertex buffers to bind
  96057. * @param indexBuffer defines the index buffer to bind
  96058. * @param effect defines the effect associated with the vertex buffers
  96059. */
  96060. bindBuffers(vertexBuffers: {
  96061. [key: string]: Nullable<VertexBuffer>;
  96062. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96063. /**
  96064. * Unbind all instance attributes
  96065. */
  96066. unbindInstanceAttributes(): void;
  96067. /**
  96068. * Release and free the memory of a vertex array object
  96069. * @param vao defines the vertex array object to delete
  96070. */
  96071. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96072. /** @hidden */
  96073. _releaseBuffer(buffer: DataBuffer): boolean;
  96074. protected _deleteBuffer(buffer: DataBuffer): void;
  96075. /**
  96076. * Creates a webGL buffer to use with instanciation
  96077. * @param capacity defines the size of the buffer
  96078. * @returns the webGL buffer
  96079. */
  96080. createInstancesBuffer(capacity: number): DataBuffer;
  96081. /**
  96082. * Delete a webGL buffer used with instanciation
  96083. * @param buffer defines the webGL buffer to delete
  96084. */
  96085. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96086. /**
  96087. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96088. * @param instancesBuffer defines the webGL buffer to update and bind
  96089. * @param data defines the data to store in the buffer
  96090. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96091. */
  96092. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96093. /**
  96094. * Apply all cached states (depth, culling, stencil and alpha)
  96095. */
  96096. applyStates(): void;
  96097. /**
  96098. * Send a draw order
  96099. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96100. * @param indexStart defines the starting index
  96101. * @param indexCount defines the number of index to draw
  96102. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96103. */
  96104. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96105. /**
  96106. * Draw a list of points
  96107. * @param verticesStart defines the index of first vertex to draw
  96108. * @param verticesCount defines the count of vertices to draw
  96109. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96110. */
  96111. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96112. /**
  96113. * Draw a list of unindexed primitives
  96114. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96115. * @param verticesStart defines the index of first vertex to draw
  96116. * @param verticesCount defines the count of vertices to draw
  96117. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96118. */
  96119. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96120. /**
  96121. * Draw a list of indexed primitives
  96122. * @param fillMode defines the primitive to use
  96123. * @param indexStart defines the starting index
  96124. * @param indexCount defines the number of index to draw
  96125. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96126. */
  96127. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96128. /**
  96129. * Draw a list of unindexed primitives
  96130. * @param fillMode defines the primitive to use
  96131. * @param verticesStart defines the index of first vertex to draw
  96132. * @param verticesCount defines the count of vertices to draw
  96133. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96134. */
  96135. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96136. private _drawMode;
  96137. /** @hidden */
  96138. _releaseEffect(effect: Effect): void;
  96139. /** @hidden */
  96140. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96141. /**
  96142. * Create a new effect (used to store vertex/fragment shaders)
  96143. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96144. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  96145. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96146. * @param samplers defines an array of string used to represent textures
  96147. * @param defines defines the string containing the defines to use to compile the shaders
  96148. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96149. * @param onCompiled defines a function to call when the effect creation is successful
  96150. * @param onError defines a function to call when the effect creation has failed
  96151. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96152. * @returns the new Effect
  96153. */
  96154. 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;
  96155. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96156. private _compileShader;
  96157. private _compileRawShader;
  96158. /**
  96159. * Directly creates a webGL program
  96160. * @param pipelineContext defines the pipeline context to attach to
  96161. * @param vertexCode defines the vertex shader code to use
  96162. * @param fragmentCode defines the fragment shader code to use
  96163. * @param context defines the webGL context to use (if not set, the current one will be used)
  96164. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96165. * @returns the new webGL program
  96166. */
  96167. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96168. /**
  96169. * Creates a webGL program
  96170. * @param pipelineContext defines the pipeline context to attach to
  96171. * @param vertexCode defines the vertex shader code to use
  96172. * @param fragmentCode defines the fragment shader code to use
  96173. * @param defines defines the string containing the defines to use to compile the shaders
  96174. * @param context defines the webGL context to use (if not set, the current one will be used)
  96175. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96176. * @returns the new webGL program
  96177. */
  96178. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96179. /**
  96180. * Creates a new pipeline context
  96181. * @returns the new pipeline
  96182. */
  96183. createPipelineContext(): IPipelineContext;
  96184. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96185. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  96186. /** @hidden */
  96187. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96188. /** @hidden */
  96189. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96190. /** @hidden */
  96191. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96192. /**
  96193. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96194. * @param pipelineContext defines the pipeline context to use
  96195. * @param uniformsNames defines the list of uniform names
  96196. * @returns an array of webGL uniform locations
  96197. */
  96198. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96199. /**
  96200. * Gets the lsit of active attributes for a given webGL program
  96201. * @param pipelineContext defines the pipeline context to use
  96202. * @param attributesNames defines the list of attribute names to get
  96203. * @returns an array of indices indicating the offset of each attribute
  96204. */
  96205. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96206. /**
  96207. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96208. * @param effect defines the effect to activate
  96209. */
  96210. enableEffect(effect: Nullable<Effect>): void;
  96211. /**
  96212. * Set the value of an uniform to an array of int32
  96213. * @param uniform defines the webGL uniform location where to store the value
  96214. * @param array defines the array of int32 to store
  96215. */
  96216. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96217. /**
  96218. * Set the value of an uniform to an array of int32 (stored as vec2)
  96219. * @param uniform defines the webGL uniform location where to store the value
  96220. * @param array defines the array of int32 to store
  96221. */
  96222. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96223. /**
  96224. * Set the value of an uniform to an array of int32 (stored as vec3)
  96225. * @param uniform defines the webGL uniform location where to store the value
  96226. * @param array defines the array of int32 to store
  96227. */
  96228. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96229. /**
  96230. * Set the value of an uniform to an array of int32 (stored as vec4)
  96231. * @param uniform defines the webGL uniform location where to store the value
  96232. * @param array defines the array of int32 to store
  96233. */
  96234. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96235. /**
  96236. * Set the value of an uniform to an array of float32
  96237. * @param uniform defines the webGL uniform location where to store the value
  96238. * @param array defines the array of float32 to store
  96239. */
  96240. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96241. /**
  96242. * Set the value of an uniform to an array of float32 (stored as vec2)
  96243. * @param uniform defines the webGL uniform location where to store the value
  96244. * @param array defines the array of float32 to store
  96245. */
  96246. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96247. /**
  96248. * Set the value of an uniform to an array of float32 (stored as vec3)
  96249. * @param uniform defines the webGL uniform location where to store the value
  96250. * @param array defines the array of float32 to store
  96251. */
  96252. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96253. /**
  96254. * Set the value of an uniform to an array of float32 (stored as vec4)
  96255. * @param uniform defines the webGL uniform location where to store the value
  96256. * @param array defines the array of float32 to store
  96257. */
  96258. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96259. /**
  96260. * Set the value of an uniform to an array of number
  96261. * @param uniform defines the webGL uniform location where to store the value
  96262. * @param array defines the array of number to store
  96263. */
  96264. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96265. /**
  96266. * Set the value of an uniform to an array of number (stored as vec2)
  96267. * @param uniform defines the webGL uniform location where to store the value
  96268. * @param array defines the array of number to store
  96269. */
  96270. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96271. /**
  96272. * Set the value of an uniform to an array of number (stored as vec3)
  96273. * @param uniform defines the webGL uniform location where to store the value
  96274. * @param array defines the array of number to store
  96275. */
  96276. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96277. /**
  96278. * Set the value of an uniform to an array of number (stored as vec4)
  96279. * @param uniform defines the webGL uniform location where to store the value
  96280. * @param array defines the array of number to store
  96281. */
  96282. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96283. /**
  96284. * Set the value of an uniform to an array of float32 (stored as matrices)
  96285. * @param uniform defines the webGL uniform location where to store the value
  96286. * @param matrices defines the array of float32 to store
  96287. */
  96288. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96289. /**
  96290. * Set the value of an uniform to a matrix (3x3)
  96291. * @param uniform defines the webGL uniform location where to store the value
  96292. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96293. */
  96294. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96295. /**
  96296. * Set the value of an uniform to a matrix (2x2)
  96297. * @param uniform defines the webGL uniform location where to store the value
  96298. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96299. */
  96300. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96301. /**
  96302. * Set the value of an uniform to a number (int)
  96303. * @param uniform defines the webGL uniform location where to store the value
  96304. * @param value defines the int number to store
  96305. */
  96306. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96307. /**
  96308. * Set the value of an uniform to a number (float)
  96309. * @param uniform defines the webGL uniform location where to store the value
  96310. * @param value defines the float number to store
  96311. */
  96312. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96313. /**
  96314. * Set the value of an uniform to a vec2
  96315. * @param uniform defines the webGL uniform location where to store the value
  96316. * @param x defines the 1st component of the value
  96317. * @param y defines the 2nd component of the value
  96318. */
  96319. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96320. /**
  96321. * Set the value of an uniform to a vec3
  96322. * @param uniform defines the webGL uniform location where to store the value
  96323. * @param x defines the 1st component of the value
  96324. * @param y defines the 2nd component of the value
  96325. * @param z defines the 3rd component of the value
  96326. */
  96327. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96328. /**
  96329. * Set the value of an uniform to a boolean
  96330. * @param uniform defines the webGL uniform location where to store the value
  96331. * @param bool defines the boolean to store
  96332. */
  96333. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96334. /**
  96335. * Set the value of an uniform to a vec4
  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. * @param w defines the 4th component of the value
  96341. */
  96342. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96343. /**
  96344. * Sets a Color4 on a uniform variable
  96345. * @param uniform defines the uniform location
  96346. * @param color4 defines the value to be set
  96347. */
  96348. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96349. /**
  96350. * Gets the depth culling state manager
  96351. */
  96352. readonly depthCullingState: DepthCullingState;
  96353. /**
  96354. * Gets the alpha state manager
  96355. */
  96356. readonly alphaState: AlphaState;
  96357. /**
  96358. * Gets the stencil state manager
  96359. */
  96360. readonly stencilState: StencilState;
  96361. /**
  96362. * Clears the list of texture accessible through engine.
  96363. * This can help preventing texture load conflict due to name collision.
  96364. */
  96365. clearInternalTexturesCache(): void;
  96366. /**
  96367. * Force the entire cache to be cleared
  96368. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96369. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96370. */
  96371. wipeCaches(bruteForce?: boolean): void;
  96372. /** @hidden */
  96373. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96374. min: number;
  96375. mag: number;
  96376. };
  96377. /** @hidden */
  96378. _createTexture(): WebGLTexture;
  96379. /**
  96380. * Usually called from Texture.ts.
  96381. * Passed information to create a WebGLTexture
  96382. * @param urlArg defines a value which contains one of the following:
  96383. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96384. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96385. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96386. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96387. * @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)
  96388. * @param scene needed for loading to the correct scene
  96389. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96390. * @param onLoad optional callback to be called upon successful completion
  96391. * @param onError optional callback to be called upon failure
  96392. * @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
  96393. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96394. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96395. * @param forcedExtension defines the extension to use to pick the right loader
  96396. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96397. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96398. */
  96399. 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;
  96400. /**
  96401. * @hidden
  96402. */
  96403. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  96404. /**
  96405. * Creates a raw texture
  96406. * @param data defines the data to store in the texture
  96407. * @param width defines the width of the texture
  96408. * @param height defines the height of the texture
  96409. * @param format defines the format of the data
  96410. * @param generateMipMaps defines if the engine should generate the mip levels
  96411. * @param invertY defines if data must be stored with Y axis inverted
  96412. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96413. * @param compression defines the compression used (null by default)
  96414. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  96415. * @returns the raw texture inside an InternalTexture
  96416. */
  96417. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  96418. /**
  96419. * Creates a new raw cube texture
  96420. * @param data defines the array of data to use to create each face
  96421. * @param size defines the size of the textures
  96422. * @param format defines the format of the data
  96423. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  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 (like Texture.NEAREST_SAMPLINGMODE)
  96427. * @param compression defines the compression used (null by default)
  96428. * @returns the cube texture as an InternalTexture
  96429. */
  96430. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  96431. /**
  96432. * Creates a new raw 3D texture
  96433. * @param data defines the data used to create the texture
  96434. * @param width defines the width of the texture
  96435. * @param height defines the height of the texture
  96436. * @param depth defines the depth of the texture
  96437. * @param format defines the format of the texture
  96438. * @param generateMipMaps defines if the engine must generate 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 compressed used (can be null)
  96442. * @param textureType defines the compressed used (can be null)
  96443. * @returns a new raw 3D texture (stored in an InternalTexture)
  96444. */
  96445. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  96446. private _unpackFlipYCached;
  96447. /**
  96448. * In case you are sharing the context with other applications, it might
  96449. * be interested to not cache the unpack flip y state to ensure a consistent
  96450. * value would be set.
  96451. */
  96452. enableUnpackFlipYCached: boolean;
  96453. /** @hidden */
  96454. _unpackFlipY(value: boolean): void;
  96455. /** @hidden */
  96456. _getUnpackAlignement(): number;
  96457. /**
  96458. * Update the sampling mode of a given texture
  96459. * @param samplingMode defines the required sampling mode
  96460. * @param texture defines the texture to update
  96461. */
  96462. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96463. /**
  96464. * Updates a depth texture Comparison Mode and Function.
  96465. * If the comparison Function is equal to 0, the mode will be set to none.
  96466. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  96467. * @param texture The texture to set the comparison function for
  96468. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  96469. */
  96470. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  96471. /** @hidden */
  96472. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  96473. width: number;
  96474. height: number;
  96475. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  96476. /**
  96477. * Creates a depth stencil texture.
  96478. * This is only available in WebGL 2 or with the depth texture extension available.
  96479. * @param size The size of face edge in the texture.
  96480. * @param options The options defining the texture.
  96481. * @returns The texture
  96482. */
  96483. createDepthStencilTexture(size: number | {
  96484. width: number;
  96485. height: number;
  96486. }, options: DepthTextureCreationOptions): InternalTexture;
  96487. /**
  96488. * Creates a depth stencil texture.
  96489. * This is only available in WebGL 2 or with the depth texture extension available.
  96490. * @param size The size of face edge in the texture.
  96491. * @param options The options defining the texture.
  96492. * @returns The texture
  96493. */
  96494. private _createDepthStencilTexture;
  96495. /**
  96496. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  96497. * @param renderTarget The render target to set the frame buffer for
  96498. */
  96499. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  96500. /** @hidden */
  96501. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  96502. /** @hidden */
  96503. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96504. /** @hidden */
  96505. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  96506. /** @hidden */
  96507. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96508. /** @hidden */
  96509. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96510. /**
  96511. * @hidden
  96512. */
  96513. _setCubeMapTextureParams(loadMipmap: boolean): void;
  96514. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  96515. private _prepareWebGLTexture;
  96516. /** @hidden */
  96517. _releaseFramebufferObjects(texture: InternalTexture): void;
  96518. /** @hidden */
  96519. _releaseTexture(texture: InternalTexture): void;
  96520. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  96521. protected _setProgram(program: WebGLProgram): void;
  96522. protected _boundUniforms: {
  96523. [key: number]: WebGLUniformLocation;
  96524. };
  96525. /**
  96526. * Binds an effect to the webGL context
  96527. * @param effect defines the effect to bind
  96528. */
  96529. bindSamplers(effect: Effect): void;
  96530. private _activateCurrentTexture;
  96531. /** @hidden */
  96532. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  96533. /** @hidden */
  96534. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  96535. /**
  96536. * Unbind all textures from the webGL context
  96537. */
  96538. unbindAllTextures(): void;
  96539. /**
  96540. * Sets a texture to the according uniform.
  96541. * @param channel The texture channel
  96542. * @param uniform The uniform to set
  96543. * @param texture The texture to apply
  96544. */
  96545. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  96546. private _bindSamplerUniformToChannel;
  96547. private _getTextureWrapMode;
  96548. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  96549. /**
  96550. * Sets an array of texture to the webGL context
  96551. * @param channel defines the channel where the texture array must be set
  96552. * @param uniform defines the associated uniform location
  96553. * @param textures defines the array of textures to bind
  96554. */
  96555. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  96556. /** @hidden */
  96557. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  96558. private _setTextureParameterFloat;
  96559. private _setTextureParameterInteger;
  96560. /**
  96561. * Unbind all vertex attributes from the webGL context
  96562. */
  96563. unbindAllAttributes(): void;
  96564. /**
  96565. * 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
  96566. */
  96567. releaseEffects(): void;
  96568. /**
  96569. * Dispose and release all associated resources
  96570. */
  96571. dispose(): void;
  96572. /**
  96573. * Attach a new callback raised when context lost event is fired
  96574. * @param callback defines the callback to call
  96575. */
  96576. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96577. /**
  96578. * Attach a new callback raised when context restored event is fired
  96579. * @param callback defines the callback to call
  96580. */
  96581. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96582. /**
  96583. * Get the current error code of the webGL context
  96584. * @returns the error code
  96585. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96586. */
  96587. getError(): number;
  96588. private _canRenderToFloatFramebuffer;
  96589. private _canRenderToHalfFloatFramebuffer;
  96590. private _canRenderToFramebuffer;
  96591. /** @hidden */
  96592. _getWebGLTextureType(type: number): number;
  96593. /** @hidden */
  96594. _getInternalFormat(format: number): number;
  96595. /** @hidden */
  96596. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  96597. /** @hidden */
  96598. _getRGBAMultiSampleBufferFormat(type: number): number;
  96599. /** @hidden */
  96600. _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;
  96601. /**
  96602. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  96603. * @returns true if the engine can be created
  96604. * @ignorenaming
  96605. */
  96606. static isSupported(): boolean;
  96607. /**
  96608. * Find the next highest power of two.
  96609. * @param x Number to start search from.
  96610. * @return Next highest power of two.
  96611. */
  96612. static CeilingPOT(x: number): number;
  96613. /**
  96614. * Find the next lowest power of two.
  96615. * @param x Number to start search from.
  96616. * @return Next lowest power of two.
  96617. */
  96618. static FloorPOT(x: number): number;
  96619. /**
  96620. * Find the nearest power of two.
  96621. * @param x Number to start search from.
  96622. * @return Next nearest power of two.
  96623. */
  96624. static NearestPOT(x: number): number;
  96625. /**
  96626. * Get the closest exponent of two
  96627. * @param value defines the value to approximate
  96628. * @param max defines the maximum value to return
  96629. * @param mode defines how to define the closest value
  96630. * @returns closest exponent of two of the given value
  96631. */
  96632. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  96633. /**
  96634. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  96635. * @param func - the function to be called
  96636. * @param requester - the object that will request the next frame. Falls back to window.
  96637. * @returns frame number
  96638. */
  96639. static QueueNewFrame(func: () => void, requester?: any): number;
  96640. }
  96641. }
  96642. declare module BABYLON {
  96643. /**
  96644. * Class used to store data associated with WebGL texture data for the engine
  96645. * This class should not be used directly
  96646. */
  96647. export class InternalTexture {
  96648. /** @hidden */
  96649. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  96650. /**
  96651. * The source of the texture data is unknown
  96652. */
  96653. static DATASOURCE_UNKNOWN: number;
  96654. /**
  96655. * Texture data comes from an URL
  96656. */
  96657. static DATASOURCE_URL: number;
  96658. /**
  96659. * Texture data is only used for temporary storage
  96660. */
  96661. static DATASOURCE_TEMP: number;
  96662. /**
  96663. * Texture data comes from raw data (ArrayBuffer)
  96664. */
  96665. static DATASOURCE_RAW: number;
  96666. /**
  96667. * Texture content is dynamic (video or dynamic texture)
  96668. */
  96669. static DATASOURCE_DYNAMIC: number;
  96670. /**
  96671. * Texture content is generated by rendering to it
  96672. */
  96673. static DATASOURCE_RENDERTARGET: number;
  96674. /**
  96675. * Texture content is part of a multi render target process
  96676. */
  96677. static DATASOURCE_MULTIRENDERTARGET: number;
  96678. /**
  96679. * Texture data comes from a cube data file
  96680. */
  96681. static DATASOURCE_CUBE: number;
  96682. /**
  96683. * Texture data comes from a raw cube data
  96684. */
  96685. static DATASOURCE_CUBERAW: number;
  96686. /**
  96687. * Texture data come from a prefiltered cube data file
  96688. */
  96689. static DATASOURCE_CUBEPREFILTERED: number;
  96690. /**
  96691. * Texture content is raw 3D data
  96692. */
  96693. static DATASOURCE_RAW3D: number;
  96694. /**
  96695. * Texture content is a depth texture
  96696. */
  96697. static DATASOURCE_DEPTHTEXTURE: number;
  96698. /**
  96699. * Texture data comes from a raw cube data encoded with RGBD
  96700. */
  96701. static DATASOURCE_CUBERAW_RGBD: number;
  96702. /**
  96703. * Defines if the texture is ready
  96704. */
  96705. isReady: boolean;
  96706. /**
  96707. * Defines if the texture is a cube texture
  96708. */
  96709. isCube: boolean;
  96710. /**
  96711. * Defines if the texture contains 3D data
  96712. */
  96713. is3D: boolean;
  96714. /**
  96715. * Defines if the texture contains multiview data
  96716. */
  96717. isMultiview: boolean;
  96718. /**
  96719. * Gets the URL used to load this texture
  96720. */
  96721. url: string;
  96722. /**
  96723. * Gets the sampling mode of the texture
  96724. */
  96725. samplingMode: number;
  96726. /**
  96727. * Gets a boolean indicating if the texture needs mipmaps generation
  96728. */
  96729. generateMipMaps: boolean;
  96730. /**
  96731. * Gets the number of samples used by the texture (WebGL2+ only)
  96732. */
  96733. samples: number;
  96734. /**
  96735. * Gets the type of the texture (int, float...)
  96736. */
  96737. type: number;
  96738. /**
  96739. * Gets the format of the texture (RGB, RGBA...)
  96740. */
  96741. format: number;
  96742. /**
  96743. * Observable called when the texture is loaded
  96744. */
  96745. onLoadedObservable: Observable<InternalTexture>;
  96746. /**
  96747. * Gets the width of the texture
  96748. */
  96749. width: number;
  96750. /**
  96751. * Gets the height of the texture
  96752. */
  96753. height: number;
  96754. /**
  96755. * Gets the depth of the texture
  96756. */
  96757. depth: number;
  96758. /**
  96759. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  96760. */
  96761. baseWidth: number;
  96762. /**
  96763. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  96764. */
  96765. baseHeight: number;
  96766. /**
  96767. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  96768. */
  96769. baseDepth: number;
  96770. /**
  96771. * Gets a boolean indicating if the texture is inverted on Y axis
  96772. */
  96773. invertY: boolean;
  96774. /** @hidden */
  96775. _invertVScale: boolean;
  96776. /** @hidden */
  96777. _associatedChannel: number;
  96778. /** @hidden */
  96779. _dataSource: number;
  96780. /** @hidden */
  96781. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  96782. /** @hidden */
  96783. _bufferView: Nullable<ArrayBufferView>;
  96784. /** @hidden */
  96785. _bufferViewArray: Nullable<ArrayBufferView[]>;
  96786. /** @hidden */
  96787. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  96788. /** @hidden */
  96789. _size: number;
  96790. /** @hidden */
  96791. _extension: string;
  96792. /** @hidden */
  96793. _files: Nullable<string[]>;
  96794. /** @hidden */
  96795. _workingCanvas: Nullable<HTMLCanvasElement>;
  96796. /** @hidden */
  96797. _workingContext: Nullable<CanvasRenderingContext2D>;
  96798. /** @hidden */
  96799. _framebuffer: Nullable<WebGLFramebuffer>;
  96800. /** @hidden */
  96801. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  96802. /** @hidden */
  96803. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  96804. /** @hidden */
  96805. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  96806. /** @hidden */
  96807. _attachments: Nullable<number[]>;
  96808. /** @hidden */
  96809. _cachedCoordinatesMode: Nullable<number>;
  96810. /** @hidden */
  96811. _cachedWrapU: Nullable<number>;
  96812. /** @hidden */
  96813. _cachedWrapV: Nullable<number>;
  96814. /** @hidden */
  96815. _cachedWrapR: Nullable<number>;
  96816. /** @hidden */
  96817. _cachedAnisotropicFilteringLevel: Nullable<number>;
  96818. /** @hidden */
  96819. _isDisabled: boolean;
  96820. /** @hidden */
  96821. _compression: Nullable<string>;
  96822. /** @hidden */
  96823. _generateStencilBuffer: boolean;
  96824. /** @hidden */
  96825. _generateDepthBuffer: boolean;
  96826. /** @hidden */
  96827. _comparisonFunction: number;
  96828. /** @hidden */
  96829. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  96830. /** @hidden */
  96831. _lodGenerationScale: number;
  96832. /** @hidden */
  96833. _lodGenerationOffset: number;
  96834. /** @hidden */
  96835. _colorTextureArray: Nullable<WebGLTexture>;
  96836. /** @hidden */
  96837. _depthStencilTextureArray: Nullable<WebGLTexture>;
  96838. /** @hidden */
  96839. _lodTextureHigh: Nullable<BaseTexture>;
  96840. /** @hidden */
  96841. _lodTextureMid: Nullable<BaseTexture>;
  96842. /** @hidden */
  96843. _lodTextureLow: Nullable<BaseTexture>;
  96844. /** @hidden */
  96845. _isRGBD: boolean;
  96846. /** @hidden */
  96847. _linearSpecularLOD: boolean;
  96848. /** @hidden */
  96849. _irradianceTexture: Nullable<BaseTexture>;
  96850. /** @hidden */
  96851. _webGLTexture: Nullable<WebGLTexture>;
  96852. /** @hidden */
  96853. _references: number;
  96854. private _engine;
  96855. /**
  96856. * Gets the Engine the texture belongs to.
  96857. * @returns The babylon engine
  96858. */
  96859. getEngine(): ThinEngine;
  96860. /**
  96861. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  96862. */
  96863. readonly dataSource: number;
  96864. /**
  96865. * Creates a new InternalTexture
  96866. * @param engine defines the engine to use
  96867. * @param dataSource defines the type of data that will be used
  96868. * @param delayAllocation if the texture allocation should be delayed (default: false)
  96869. */
  96870. constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
  96871. /**
  96872. * Increments the number of references (ie. the number of Texture that point to it)
  96873. */
  96874. incrementReferences(): void;
  96875. /**
  96876. * Change the size of the texture (not the size of the content)
  96877. * @param width defines the new width
  96878. * @param height defines the new height
  96879. * @param depth defines the new depth (1 by default)
  96880. */
  96881. updateSize(width: int, height: int, depth?: int): void;
  96882. /** @hidden */
  96883. _rebuild(): void;
  96884. /** @hidden */
  96885. _swapAndDie(target: InternalTexture): void;
  96886. /**
  96887. * Dispose the current allocated resources
  96888. */
  96889. dispose(): void;
  96890. }
  96891. }
  96892. declare module BABYLON {
  96893. /**
  96894. * Class used to work with sound analyzer using fast fourier transform (FFT)
  96895. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96896. */
  96897. export class Analyser {
  96898. /**
  96899. * Gets or sets the smoothing
  96900. * @ignorenaming
  96901. */
  96902. SMOOTHING: number;
  96903. /**
  96904. * Gets or sets the FFT table size
  96905. * @ignorenaming
  96906. */
  96907. FFT_SIZE: number;
  96908. /**
  96909. * Gets or sets the bar graph amplitude
  96910. * @ignorenaming
  96911. */
  96912. BARGRAPHAMPLITUDE: number;
  96913. /**
  96914. * Gets or sets the position of the debug canvas
  96915. * @ignorenaming
  96916. */
  96917. DEBUGCANVASPOS: {
  96918. x: number;
  96919. y: number;
  96920. };
  96921. /**
  96922. * Gets or sets the debug canvas size
  96923. * @ignorenaming
  96924. */
  96925. DEBUGCANVASSIZE: {
  96926. width: number;
  96927. height: number;
  96928. };
  96929. private _byteFreqs;
  96930. private _byteTime;
  96931. private _floatFreqs;
  96932. private _webAudioAnalyser;
  96933. private _debugCanvas;
  96934. private _debugCanvasContext;
  96935. private _scene;
  96936. private _registerFunc;
  96937. private _audioEngine;
  96938. /**
  96939. * Creates a new analyser
  96940. * @param scene defines hosting scene
  96941. */
  96942. constructor(scene: Scene);
  96943. /**
  96944. * Get the number of data values you will have to play with for the visualization
  96945. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  96946. * @returns a number
  96947. */
  96948. getFrequencyBinCount(): number;
  96949. /**
  96950. * Gets the current frequency data as a byte array
  96951. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  96952. * @returns a Uint8Array
  96953. */
  96954. getByteFrequencyData(): Uint8Array;
  96955. /**
  96956. * Gets the current waveform as a byte array
  96957. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  96958. * @returns a Uint8Array
  96959. */
  96960. getByteTimeDomainData(): Uint8Array;
  96961. /**
  96962. * Gets the current frequency data as a float array
  96963. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  96964. * @returns a Float32Array
  96965. */
  96966. getFloatFrequencyData(): Float32Array;
  96967. /**
  96968. * Renders the debug canvas
  96969. */
  96970. drawDebugCanvas(): void;
  96971. /**
  96972. * Stops rendering the debug canvas and removes it
  96973. */
  96974. stopDebugCanvas(): void;
  96975. /**
  96976. * Connects two audio nodes
  96977. * @param inputAudioNode defines first node to connect
  96978. * @param outputAudioNode defines second node to connect
  96979. */
  96980. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  96981. /**
  96982. * Releases all associated resources
  96983. */
  96984. dispose(): void;
  96985. }
  96986. }
  96987. declare module BABYLON {
  96988. /**
  96989. * This represents an audio engine and it is responsible
  96990. * to play, synchronize and analyse sounds throughout the application.
  96991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96992. */
  96993. export interface IAudioEngine extends IDisposable {
  96994. /**
  96995. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  96996. */
  96997. readonly canUseWebAudio: boolean;
  96998. /**
  96999. * Gets the current AudioContext if available.
  97000. */
  97001. readonly audioContext: Nullable<AudioContext>;
  97002. /**
  97003. * The master gain node defines the global audio volume of your audio engine.
  97004. */
  97005. readonly masterGain: GainNode;
  97006. /**
  97007. * Gets whether or not mp3 are supported by your browser.
  97008. */
  97009. readonly isMP3supported: boolean;
  97010. /**
  97011. * Gets whether or not ogg are supported by your browser.
  97012. */
  97013. readonly isOGGsupported: boolean;
  97014. /**
  97015. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97016. * @ignoreNaming
  97017. */
  97018. WarnedWebAudioUnsupported: boolean;
  97019. /**
  97020. * Defines if the audio engine relies on a custom unlocked button.
  97021. * In this case, the embedded button will not be displayed.
  97022. */
  97023. useCustomUnlockedButton: boolean;
  97024. /**
  97025. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  97026. */
  97027. readonly unlocked: boolean;
  97028. /**
  97029. * Event raised when audio has been unlocked on the browser.
  97030. */
  97031. onAudioUnlockedObservable: Observable<AudioEngine>;
  97032. /**
  97033. * Event raised when audio has been locked on the browser.
  97034. */
  97035. onAudioLockedObservable: Observable<AudioEngine>;
  97036. /**
  97037. * Flags the audio engine in Locked state.
  97038. * This happens due to new browser policies preventing audio to autoplay.
  97039. */
  97040. lock(): void;
  97041. /**
  97042. * Unlocks the audio engine once a user action has been done on the dom.
  97043. * This is helpful to resume play once browser policies have been satisfied.
  97044. */
  97045. unlock(): void;
  97046. }
  97047. /**
  97048. * This represents the default audio engine used in babylon.
  97049. * It is responsible to play, synchronize and analyse sounds throughout the application.
  97050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97051. */
  97052. export class AudioEngine implements IAudioEngine {
  97053. private _audioContext;
  97054. private _audioContextInitialized;
  97055. private _muteButton;
  97056. private _hostElement;
  97057. /**
  97058. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97059. */
  97060. canUseWebAudio: boolean;
  97061. /**
  97062. * The master gain node defines the global audio volume of your audio engine.
  97063. */
  97064. masterGain: GainNode;
  97065. /**
  97066. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97067. * @ignoreNaming
  97068. */
  97069. WarnedWebAudioUnsupported: boolean;
  97070. /**
  97071. * Gets whether or not mp3 are supported by your browser.
  97072. */
  97073. isMP3supported: boolean;
  97074. /**
  97075. * Gets whether or not ogg are supported by your browser.
  97076. */
  97077. isOGGsupported: boolean;
  97078. /**
  97079. * Gets whether audio has been unlocked on the device.
  97080. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  97081. * a user interaction has happened.
  97082. */
  97083. unlocked: boolean;
  97084. /**
  97085. * Defines if the audio engine relies on a custom unlocked button.
  97086. * In this case, the embedded button will not be displayed.
  97087. */
  97088. useCustomUnlockedButton: boolean;
  97089. /**
  97090. * Event raised when audio has been unlocked on the browser.
  97091. */
  97092. onAudioUnlockedObservable: Observable<AudioEngine>;
  97093. /**
  97094. * Event raised when audio has been locked on the browser.
  97095. */
  97096. onAudioLockedObservable: Observable<AudioEngine>;
  97097. /**
  97098. * Gets the current AudioContext if available.
  97099. */
  97100. readonly audioContext: Nullable<AudioContext>;
  97101. private _connectedAnalyser;
  97102. /**
  97103. * Instantiates a new audio engine.
  97104. *
  97105. * There should be only one per page as some browsers restrict the number
  97106. * of audio contexts you can create.
  97107. * @param hostElement defines the host element where to display the mute icon if necessary
  97108. */
  97109. constructor(hostElement?: Nullable<HTMLElement>);
  97110. /**
  97111. * Flags the audio engine in Locked state.
  97112. * This happens due to new browser policies preventing audio to autoplay.
  97113. */
  97114. lock(): void;
  97115. /**
  97116. * Unlocks the audio engine once a user action has been done on the dom.
  97117. * This is helpful to resume play once browser policies have been satisfied.
  97118. */
  97119. unlock(): void;
  97120. private _resumeAudioContext;
  97121. private _initializeAudioContext;
  97122. private _tryToRun;
  97123. private _triggerRunningState;
  97124. private _triggerSuspendedState;
  97125. private _displayMuteButton;
  97126. private _moveButtonToTopLeft;
  97127. private _onResize;
  97128. private _hideMuteButton;
  97129. /**
  97130. * Destroy and release the resources associated with the audio ccontext.
  97131. */
  97132. dispose(): void;
  97133. /**
  97134. * Gets the global volume sets on the master gain.
  97135. * @returns the global volume if set or -1 otherwise
  97136. */
  97137. getGlobalVolume(): number;
  97138. /**
  97139. * Sets the global volume of your experience (sets on the master gain).
  97140. * @param newVolume Defines the new global volume of the application
  97141. */
  97142. setGlobalVolume(newVolume: number): void;
  97143. /**
  97144. * Connect the audio engine to an audio analyser allowing some amazing
  97145. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97146. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97147. * @param analyser The analyser to connect to the engine
  97148. */
  97149. connectToAnalyser(analyser: Analyser): void;
  97150. }
  97151. }
  97152. declare module BABYLON {
  97153. /**
  97154. * Interface used to present a loading screen while loading a scene
  97155. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97156. */
  97157. export interface ILoadingScreen {
  97158. /**
  97159. * Function called to display the loading screen
  97160. */
  97161. displayLoadingUI: () => void;
  97162. /**
  97163. * Function called to hide the loading screen
  97164. */
  97165. hideLoadingUI: () => void;
  97166. /**
  97167. * Gets or sets the color to use for the background
  97168. */
  97169. loadingUIBackgroundColor: string;
  97170. /**
  97171. * Gets or sets the text to display while loading
  97172. */
  97173. loadingUIText: string;
  97174. }
  97175. /**
  97176. * Class used for the default loading screen
  97177. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97178. */
  97179. export class DefaultLoadingScreen implements ILoadingScreen {
  97180. private _renderingCanvas;
  97181. private _loadingText;
  97182. private _loadingDivBackgroundColor;
  97183. private _loadingDiv;
  97184. private _loadingTextDiv;
  97185. /** Gets or sets the logo url to use for the default loading screen */
  97186. static DefaultLogoUrl: string;
  97187. /** Gets or sets the spinner url to use for the default loading screen */
  97188. static DefaultSpinnerUrl: string;
  97189. /**
  97190. * Creates a new default loading screen
  97191. * @param _renderingCanvas defines the canvas used to render the scene
  97192. * @param _loadingText defines the default text to display
  97193. * @param _loadingDivBackgroundColor defines the default background color
  97194. */
  97195. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  97196. /**
  97197. * Function called to display the loading screen
  97198. */
  97199. displayLoadingUI(): void;
  97200. /**
  97201. * Function called to hide the loading screen
  97202. */
  97203. hideLoadingUI(): void;
  97204. /**
  97205. * Gets or sets the text to display while loading
  97206. */
  97207. loadingUIText: string;
  97208. /**
  97209. * Gets or sets the color to use for the background
  97210. */
  97211. loadingUIBackgroundColor: string;
  97212. private _resizeLoadingUI;
  97213. }
  97214. }
  97215. declare module BABYLON {
  97216. /**
  97217. * Interface for any object that can request an animation frame
  97218. */
  97219. export interface ICustomAnimationFrameRequester {
  97220. /**
  97221. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  97222. */
  97223. renderFunction?: Function;
  97224. /**
  97225. * Called to request the next frame to render to
  97226. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  97227. */
  97228. requestAnimationFrame: Function;
  97229. /**
  97230. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  97231. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  97232. */
  97233. requestID?: number;
  97234. }
  97235. }
  97236. declare module BABYLON {
  97237. /**
  97238. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  97239. */
  97240. export class PerformanceMonitor {
  97241. private _enabled;
  97242. private _rollingFrameTime;
  97243. private _lastFrameTimeMs;
  97244. /**
  97245. * constructor
  97246. * @param frameSampleSize The number of samples required to saturate the sliding window
  97247. */
  97248. constructor(frameSampleSize?: number);
  97249. /**
  97250. * Samples current frame
  97251. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  97252. */
  97253. sampleFrame(timeMs?: number): void;
  97254. /**
  97255. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97256. */
  97257. readonly averageFrameTime: number;
  97258. /**
  97259. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97260. */
  97261. readonly averageFrameTimeVariance: number;
  97262. /**
  97263. * Returns the frame time of the most recent frame
  97264. */
  97265. readonly instantaneousFrameTime: number;
  97266. /**
  97267. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  97268. */
  97269. readonly averageFPS: number;
  97270. /**
  97271. * Returns the average framerate in frames per second using the most recent frame time
  97272. */
  97273. readonly instantaneousFPS: number;
  97274. /**
  97275. * Returns true if enough samples have been taken to completely fill the sliding window
  97276. */
  97277. readonly isSaturated: boolean;
  97278. /**
  97279. * Enables contributions to the sliding window sample set
  97280. */
  97281. enable(): void;
  97282. /**
  97283. * Disables contributions to the sliding window sample set
  97284. * Samples will not be interpolated over the disabled period
  97285. */
  97286. disable(): void;
  97287. /**
  97288. * Returns true if sampling is enabled
  97289. */
  97290. readonly isEnabled: boolean;
  97291. /**
  97292. * Resets performance monitor
  97293. */
  97294. reset(): void;
  97295. }
  97296. /**
  97297. * RollingAverage
  97298. *
  97299. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  97300. */
  97301. export class RollingAverage {
  97302. /**
  97303. * Current average
  97304. */
  97305. average: number;
  97306. /**
  97307. * Current variance
  97308. */
  97309. variance: number;
  97310. protected _samples: Array<number>;
  97311. protected _sampleCount: number;
  97312. protected _pos: number;
  97313. protected _m2: number;
  97314. /**
  97315. * constructor
  97316. * @param length The number of samples required to saturate the sliding window
  97317. */
  97318. constructor(length: number);
  97319. /**
  97320. * Adds a sample to the sample set
  97321. * @param v The sample value
  97322. */
  97323. add(v: number): void;
  97324. /**
  97325. * Returns previously added values or null if outside of history or outside the sliding window domain
  97326. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  97327. * @return Value previously recorded with add() or null if outside of range
  97328. */
  97329. history(i: number): number;
  97330. /**
  97331. * Returns true if enough samples have been taken to completely fill the sliding window
  97332. * @return true if sample-set saturated
  97333. */
  97334. isSaturated(): boolean;
  97335. /**
  97336. * Resets the rolling average (equivalent to 0 samples taken so far)
  97337. */
  97338. reset(): void;
  97339. /**
  97340. * Wraps a value around the sample range boundaries
  97341. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  97342. * @return Wrapped position in sample range
  97343. */
  97344. protected _wrapPosition(i: number): number;
  97345. }
  97346. }
  97347. declare module BABYLON {
  97348. /**
  97349. * Defines the interface used by display changed events
  97350. */
  97351. export interface IDisplayChangedEventArgs {
  97352. /** Gets the vrDisplay object (if any) */
  97353. vrDisplay: Nullable<any>;
  97354. /** Gets a boolean indicating if webVR is supported */
  97355. vrSupported: boolean;
  97356. }
  97357. /**
  97358. * Defines the interface used by objects containing a viewport (like a camera)
  97359. */
  97360. interface IViewportOwnerLike {
  97361. /**
  97362. * Gets or sets the viewport
  97363. */
  97364. viewport: IViewportLike;
  97365. }
  97366. /**
  97367. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  97368. */
  97369. export class Engine extends ThinEngine {
  97370. /** Defines that alpha blending is disabled */
  97371. static readonly ALPHA_DISABLE: number;
  97372. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  97373. static readonly ALPHA_ADD: number;
  97374. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  97375. static readonly ALPHA_COMBINE: number;
  97376. /** Defines that alpha blending to DEST - SRC * DEST */
  97377. static readonly ALPHA_SUBTRACT: number;
  97378. /** Defines that alpha blending to SRC * DEST */
  97379. static readonly ALPHA_MULTIPLY: number;
  97380. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  97381. static readonly ALPHA_MAXIMIZED: number;
  97382. /** Defines that alpha blending to SRC + DEST */
  97383. static readonly ALPHA_ONEONE: number;
  97384. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  97385. static readonly ALPHA_PREMULTIPLIED: number;
  97386. /**
  97387. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  97388. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  97389. */
  97390. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  97391. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  97392. static readonly ALPHA_INTERPOLATE: number;
  97393. /**
  97394. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  97395. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  97396. */
  97397. static readonly ALPHA_SCREENMODE: number;
  97398. /** Defines that the ressource is not delayed*/
  97399. static readonly DELAYLOADSTATE_NONE: number;
  97400. /** Defines that the ressource was successfully delay loaded */
  97401. static readonly DELAYLOADSTATE_LOADED: number;
  97402. /** Defines that the ressource is currently delay loading */
  97403. static readonly DELAYLOADSTATE_LOADING: number;
  97404. /** Defines that the ressource is delayed and has not started loading */
  97405. static readonly DELAYLOADSTATE_NOTLOADED: number;
  97406. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  97407. static readonly NEVER: number;
  97408. /** 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 */
  97409. static readonly ALWAYS: number;
  97410. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  97411. static readonly LESS: number;
  97412. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  97413. static readonly EQUAL: number;
  97414. /** 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 */
  97415. static readonly LEQUAL: number;
  97416. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  97417. static readonly GREATER: number;
  97418. /** 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 */
  97419. static readonly GEQUAL: number;
  97420. /** 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 */
  97421. static readonly NOTEQUAL: number;
  97422. /** Passed to stencilOperation to specify that stencil value must be kept */
  97423. static readonly KEEP: number;
  97424. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97425. static readonly REPLACE: number;
  97426. /** Passed to stencilOperation to specify that stencil value must be incremented */
  97427. static readonly INCR: number;
  97428. /** Passed to stencilOperation to specify that stencil value must be decremented */
  97429. static readonly DECR: number;
  97430. /** Passed to stencilOperation to specify that stencil value must be inverted */
  97431. static readonly INVERT: number;
  97432. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  97433. static readonly INCR_WRAP: number;
  97434. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  97435. static readonly DECR_WRAP: number;
  97436. /** Texture is not repeating outside of 0..1 UVs */
  97437. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  97438. /** Texture is repeating outside of 0..1 UVs */
  97439. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  97440. /** Texture is repeating and mirrored */
  97441. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  97442. /** ALPHA */
  97443. static readonly TEXTUREFORMAT_ALPHA: number;
  97444. /** LUMINANCE */
  97445. static readonly TEXTUREFORMAT_LUMINANCE: number;
  97446. /** LUMINANCE_ALPHA */
  97447. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  97448. /** RGB */
  97449. static readonly TEXTUREFORMAT_RGB: number;
  97450. /** RGBA */
  97451. static readonly TEXTUREFORMAT_RGBA: number;
  97452. /** RED */
  97453. static readonly TEXTUREFORMAT_RED: number;
  97454. /** RED (2nd reference) */
  97455. static readonly TEXTUREFORMAT_R: number;
  97456. /** RG */
  97457. static readonly TEXTUREFORMAT_RG: number;
  97458. /** RED_INTEGER */
  97459. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  97460. /** RED_INTEGER (2nd reference) */
  97461. static readonly TEXTUREFORMAT_R_INTEGER: number;
  97462. /** RG_INTEGER */
  97463. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  97464. /** RGB_INTEGER */
  97465. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  97466. /** RGBA_INTEGER */
  97467. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  97468. /** UNSIGNED_BYTE */
  97469. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  97470. /** UNSIGNED_BYTE (2nd reference) */
  97471. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  97472. /** FLOAT */
  97473. static readonly TEXTURETYPE_FLOAT: number;
  97474. /** HALF_FLOAT */
  97475. static readonly TEXTURETYPE_HALF_FLOAT: number;
  97476. /** BYTE */
  97477. static readonly TEXTURETYPE_BYTE: number;
  97478. /** SHORT */
  97479. static readonly TEXTURETYPE_SHORT: number;
  97480. /** UNSIGNED_SHORT */
  97481. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  97482. /** INT */
  97483. static readonly TEXTURETYPE_INT: number;
  97484. /** UNSIGNED_INT */
  97485. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  97486. /** UNSIGNED_SHORT_4_4_4_4 */
  97487. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  97488. /** UNSIGNED_SHORT_5_5_5_1 */
  97489. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  97490. /** UNSIGNED_SHORT_5_6_5 */
  97491. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  97492. /** UNSIGNED_INT_2_10_10_10_REV */
  97493. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  97494. /** UNSIGNED_INT_24_8 */
  97495. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  97496. /** UNSIGNED_INT_10F_11F_11F_REV */
  97497. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  97498. /** UNSIGNED_INT_5_9_9_9_REV */
  97499. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  97500. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  97501. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  97502. /** nearest is mag = nearest and min = nearest and mip = linear */
  97503. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  97504. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97505. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  97506. /** Trilinear is mag = linear and min = linear and mip = linear */
  97507. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  97508. /** nearest is mag = nearest and min = nearest and mip = linear */
  97509. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  97510. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97511. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  97512. /** Trilinear is mag = linear and min = linear and mip = linear */
  97513. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  97514. /** mag = nearest and min = nearest and mip = nearest */
  97515. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  97516. /** mag = nearest and min = linear and mip = nearest */
  97517. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  97518. /** mag = nearest and min = linear and mip = linear */
  97519. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  97520. /** mag = nearest and min = linear and mip = none */
  97521. static readonly TEXTURE_NEAREST_LINEAR: number;
  97522. /** mag = nearest and min = nearest and mip = none */
  97523. static readonly TEXTURE_NEAREST_NEAREST: number;
  97524. /** mag = linear and min = nearest and mip = nearest */
  97525. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  97526. /** mag = linear and min = nearest and mip = linear */
  97527. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  97528. /** mag = linear and min = linear and mip = none */
  97529. static readonly TEXTURE_LINEAR_LINEAR: number;
  97530. /** mag = linear and min = nearest and mip = none */
  97531. static readonly TEXTURE_LINEAR_NEAREST: number;
  97532. /** Explicit coordinates mode */
  97533. static readonly TEXTURE_EXPLICIT_MODE: number;
  97534. /** Spherical coordinates mode */
  97535. static readonly TEXTURE_SPHERICAL_MODE: number;
  97536. /** Planar coordinates mode */
  97537. static readonly TEXTURE_PLANAR_MODE: number;
  97538. /** Cubic coordinates mode */
  97539. static readonly TEXTURE_CUBIC_MODE: number;
  97540. /** Projection coordinates mode */
  97541. static readonly TEXTURE_PROJECTION_MODE: number;
  97542. /** Skybox coordinates mode */
  97543. static readonly TEXTURE_SKYBOX_MODE: number;
  97544. /** Inverse Cubic coordinates mode */
  97545. static readonly TEXTURE_INVCUBIC_MODE: number;
  97546. /** Equirectangular coordinates mode */
  97547. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  97548. /** Equirectangular Fixed coordinates mode */
  97549. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  97550. /** Equirectangular Fixed Mirrored coordinates mode */
  97551. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  97552. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  97553. static readonly SCALEMODE_FLOOR: number;
  97554. /** Defines that texture rescaling will look for the nearest power of 2 size */
  97555. static readonly SCALEMODE_NEAREST: number;
  97556. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  97557. static readonly SCALEMODE_CEILING: number;
  97558. /**
  97559. * Returns the current npm package of the sdk
  97560. */
  97561. static readonly NpmPackage: string;
  97562. /**
  97563. * Returns the current version of the framework
  97564. */
  97565. static readonly Version: string;
  97566. /** Gets the list of created engines */
  97567. static readonly Instances: Engine[];
  97568. /**
  97569. * Gets the latest created engine
  97570. */
  97571. static readonly LastCreatedEngine: Nullable<Engine>;
  97572. /**
  97573. * Gets the latest created scene
  97574. */
  97575. static readonly LastCreatedScene: Nullable<Scene>;
  97576. /**
  97577. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  97578. * @param flag defines which part of the materials must be marked as dirty
  97579. * @param predicate defines a predicate used to filter which materials should be affected
  97580. */
  97581. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  97582. /**
  97583. * Method called to create the default loading screen.
  97584. * This can be overriden in your own app.
  97585. * @param canvas The rendering canvas element
  97586. * @returns The loading screen
  97587. */
  97588. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  97589. /**
  97590. * Method called to create the default rescale post process on each engine.
  97591. */
  97592. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  97593. /**
  97594. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  97595. **/
  97596. enableOfflineSupport: boolean;
  97597. /**
  97598. * 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)
  97599. **/
  97600. disableManifestCheck: boolean;
  97601. /**
  97602. * Gets the list of created scenes
  97603. */
  97604. scenes: Scene[];
  97605. /**
  97606. * Event raised when a new scene is created
  97607. */
  97608. onNewSceneAddedObservable: Observable<Scene>;
  97609. /**
  97610. * Gets the list of created postprocesses
  97611. */
  97612. postProcesses: PostProcess[];
  97613. /**
  97614. * Gets a boolean indicating if the pointer is currently locked
  97615. */
  97616. isPointerLock: boolean;
  97617. /**
  97618. * Observable event triggered each time the rendering canvas is resized
  97619. */
  97620. onResizeObservable: Observable<Engine>;
  97621. /**
  97622. * Observable event triggered each time the canvas loses focus
  97623. */
  97624. onCanvasBlurObservable: Observable<Engine>;
  97625. /**
  97626. * Observable event triggered each time the canvas gains focus
  97627. */
  97628. onCanvasFocusObservable: Observable<Engine>;
  97629. /**
  97630. * Observable event triggered each time the canvas receives pointerout event
  97631. */
  97632. onCanvasPointerOutObservable: Observable<PointerEvent>;
  97633. /**
  97634. * Observable event triggered before each texture is initialized
  97635. */
  97636. onBeforeTextureInitObservable: Observable<Texture>;
  97637. /**
  97638. * Observable raised when the engine begins a new frame
  97639. */
  97640. onBeginFrameObservable: Observable<Engine>;
  97641. /**
  97642. * If set, will be used to request the next animation frame for the render loop
  97643. */
  97644. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  97645. /**
  97646. * Observable raised when the engine ends the current frame
  97647. */
  97648. onEndFrameObservable: Observable<Engine>;
  97649. /**
  97650. * Observable raised when the engine is about to compile a shader
  97651. */
  97652. onBeforeShaderCompilationObservable: Observable<Engine>;
  97653. /**
  97654. * Observable raised when the engine has jsut compiled a shader
  97655. */
  97656. onAfterShaderCompilationObservable: Observable<Engine>;
  97657. /**
  97658. * Gets the audio engine
  97659. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97660. * @ignorenaming
  97661. */
  97662. static audioEngine: IAudioEngine;
  97663. /**
  97664. * Default AudioEngine factory responsible of creating the Audio Engine.
  97665. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  97666. */
  97667. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  97668. /**
  97669. * Default offline support factory responsible of creating a tool used to store data locally.
  97670. * By default, this will create a Database object if the workload has been embedded.
  97671. */
  97672. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  97673. private _loadingScreen;
  97674. private _pointerLockRequested;
  97675. private _dummyFramebuffer;
  97676. private _rescalePostProcess;
  97677. /** @hidden */
  97678. protected _alphaMode: number;
  97679. /** @hidden */
  97680. protected _alphaEquation: number;
  97681. private _deterministicLockstep;
  97682. private _lockstepMaxSteps;
  97683. protected readonly _supportsHardwareTextureRescaling: boolean;
  97684. private _fps;
  97685. private _deltaTime;
  97686. /**
  97687. * Turn this value on if you want to pause FPS computation when in background
  97688. */
  97689. disablePerformanceMonitorInBackground: boolean;
  97690. private _performanceMonitor;
  97691. /**
  97692. * Gets the performance monitor attached to this engine
  97693. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  97694. */
  97695. readonly performanceMonitor: PerformanceMonitor;
  97696. private _onFocus;
  97697. private _onBlur;
  97698. private _onCanvasPointerOut;
  97699. private _onCanvasBlur;
  97700. private _onCanvasFocus;
  97701. private _onFullscreenChange;
  97702. private _onPointerLockChange;
  97703. /**
  97704. * Creates a new engine
  97705. * @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
  97706. * @param antialias defines enable antialiasing (default: false)
  97707. * @param options defines further options to be sent to the getContext() function
  97708. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  97709. */
  97710. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  97711. /**
  97712. * Gets current aspect ratio
  97713. * @param viewportOwner defines the camera to use to get the aspect ratio
  97714. * @param useScreen defines if screen size must be used (or the current render target if any)
  97715. * @returns a number defining the aspect ratio
  97716. */
  97717. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  97718. /**
  97719. * Gets current screen aspect ratio
  97720. * @returns a number defining the aspect ratio
  97721. */
  97722. getScreenAspectRatio(): number;
  97723. /**
  97724. * Gets host document
  97725. * @returns the host document object
  97726. */
  97727. getHostDocument(): Document;
  97728. /**
  97729. * Gets the client rect of the HTML canvas attached with the current webGL context
  97730. * @returns a client rectanglee
  97731. */
  97732. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  97733. /**
  97734. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  97735. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97736. * @returns true if engine is in deterministic lock step mode
  97737. */
  97738. isDeterministicLockStep(): boolean;
  97739. /**
  97740. * Gets the max steps when engine is running in deterministic lock step
  97741. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97742. * @returns the max steps
  97743. */
  97744. getLockstepMaxSteps(): number;
  97745. /**
  97746. * Force the mipmap generation for the given render target texture
  97747. * @param texture defines the render target texture to use
  97748. */
  97749. generateMipMapsForCubemap(texture: InternalTexture): void;
  97750. /** States */
  97751. /**
  97752. * Set various states to the webGL context
  97753. * @param culling defines backface culling state
  97754. * @param zOffset defines the value to apply to zOffset (0 by default)
  97755. * @param force defines if states must be applied even if cache is up to date
  97756. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  97757. */
  97758. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  97759. /**
  97760. * Set the z offset to apply to current rendering
  97761. * @param value defines the offset to apply
  97762. */
  97763. setZOffset(value: number): void;
  97764. /**
  97765. * Gets the current value of the zOffset
  97766. * @returns the current zOffset state
  97767. */
  97768. getZOffset(): number;
  97769. /**
  97770. * Enable or disable depth buffering
  97771. * @param enable defines the state to set
  97772. */
  97773. setDepthBuffer(enable: boolean): void;
  97774. /**
  97775. * Gets a boolean indicating if depth writing is enabled
  97776. * @returns the current depth writing state
  97777. */
  97778. getDepthWrite(): boolean;
  97779. /**
  97780. * Enable or disable depth writing
  97781. * @param enable defines the state to set
  97782. */
  97783. setDepthWrite(enable: boolean): void;
  97784. /**
  97785. * Enable or disable color writing
  97786. * @param enable defines the state to set
  97787. */
  97788. setColorWrite(enable: boolean): void;
  97789. /**
  97790. * Gets a boolean indicating if color writing is enabled
  97791. * @returns the current color writing state
  97792. */
  97793. getColorWrite(): boolean;
  97794. /**
  97795. * Sets alpha constants used by some alpha blending modes
  97796. * @param r defines the red component
  97797. * @param g defines the green component
  97798. * @param b defines the blue component
  97799. * @param a defines the alpha component
  97800. */
  97801. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  97802. /**
  97803. * Sets the current alpha mode
  97804. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  97805. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  97806. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97807. */
  97808. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  97809. /**
  97810. * Gets the current alpha mode
  97811. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97812. * @returns the current alpha mode
  97813. */
  97814. getAlphaMode(): number;
  97815. /**
  97816. * Sets the current alpha equation
  97817. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  97818. */
  97819. setAlphaEquation(equation: number): void;
  97820. /**
  97821. * Gets the current alpha equation.
  97822. * @returns the current alpha equation
  97823. */
  97824. getAlphaEquation(): number;
  97825. /**
  97826. * Gets a boolean indicating if stencil buffer is enabled
  97827. * @returns the current stencil buffer state
  97828. */
  97829. getStencilBuffer(): boolean;
  97830. /**
  97831. * Enable or disable the stencil buffer
  97832. * @param enable defines if the stencil buffer must be enabled or disabled
  97833. */
  97834. setStencilBuffer(enable: boolean): void;
  97835. /**
  97836. * Gets the current stencil mask
  97837. * @returns a number defining the new stencil mask to use
  97838. */
  97839. getStencilMask(): number;
  97840. /**
  97841. * Sets the current stencil mask
  97842. * @param mask defines the new stencil mask to use
  97843. */
  97844. setStencilMask(mask: number): void;
  97845. /**
  97846. * Gets the current stencil function
  97847. * @returns a number defining the stencil function to use
  97848. */
  97849. getStencilFunction(): number;
  97850. /**
  97851. * Gets the current stencil reference value
  97852. * @returns a number defining the stencil reference value to use
  97853. */
  97854. getStencilFunctionReference(): number;
  97855. /**
  97856. * Gets the current stencil mask
  97857. * @returns a number defining the stencil mask to use
  97858. */
  97859. getStencilFunctionMask(): number;
  97860. /**
  97861. * Sets the current stencil function
  97862. * @param stencilFunc defines the new stencil function to use
  97863. */
  97864. setStencilFunction(stencilFunc: number): void;
  97865. /**
  97866. * Sets the current stencil reference
  97867. * @param reference defines the new stencil reference to use
  97868. */
  97869. setStencilFunctionReference(reference: number): void;
  97870. /**
  97871. * Sets the current stencil mask
  97872. * @param mask defines the new stencil mask to use
  97873. */
  97874. setStencilFunctionMask(mask: number): void;
  97875. /**
  97876. * Gets the current stencil operation when stencil fails
  97877. * @returns a number defining stencil operation to use when stencil fails
  97878. */
  97879. getStencilOperationFail(): number;
  97880. /**
  97881. * Gets the current stencil operation when depth fails
  97882. * @returns a number defining stencil operation to use when depth fails
  97883. */
  97884. getStencilOperationDepthFail(): number;
  97885. /**
  97886. * Gets the current stencil operation when stencil passes
  97887. * @returns a number defining stencil operation to use when stencil passes
  97888. */
  97889. getStencilOperationPass(): number;
  97890. /**
  97891. * Sets the stencil operation to use when stencil fails
  97892. * @param operation defines the stencil operation to use when stencil fails
  97893. */
  97894. setStencilOperationFail(operation: number): void;
  97895. /**
  97896. * Sets the stencil operation to use when depth fails
  97897. * @param operation defines the stencil operation to use when depth fails
  97898. */
  97899. setStencilOperationDepthFail(operation: number): void;
  97900. /**
  97901. * Sets the stencil operation to use when stencil passes
  97902. * @param operation defines the stencil operation to use when stencil passes
  97903. */
  97904. setStencilOperationPass(operation: number): void;
  97905. /**
  97906. * Sets a boolean indicating if the dithering state is enabled or disabled
  97907. * @param value defines the dithering state
  97908. */
  97909. setDitheringState(value: boolean): void;
  97910. /**
  97911. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  97912. * @param value defines the rasterizer state
  97913. */
  97914. setRasterizerState(value: boolean): void;
  97915. /**
  97916. * Gets the current depth function
  97917. * @returns a number defining the depth function
  97918. */
  97919. getDepthFunction(): Nullable<number>;
  97920. /**
  97921. * Sets the current depth function
  97922. * @param depthFunc defines the function to use
  97923. */
  97924. setDepthFunction(depthFunc: number): void;
  97925. /**
  97926. * Sets the current depth function to GREATER
  97927. */
  97928. setDepthFunctionToGreater(): void;
  97929. /**
  97930. * Sets the current depth function to GEQUAL
  97931. */
  97932. setDepthFunctionToGreaterOrEqual(): void;
  97933. /**
  97934. * Sets the current depth function to LESS
  97935. */
  97936. setDepthFunctionToLess(): void;
  97937. /**
  97938. * Sets the current depth function to LEQUAL
  97939. */
  97940. setDepthFunctionToLessOrEqual(): void;
  97941. private _cachedStencilBuffer;
  97942. private _cachedStencilFunction;
  97943. private _cachedStencilMask;
  97944. private _cachedStencilOperationPass;
  97945. private _cachedStencilOperationFail;
  97946. private _cachedStencilOperationDepthFail;
  97947. private _cachedStencilReference;
  97948. /**
  97949. * Caches the the state of the stencil buffer
  97950. */
  97951. cacheStencilState(): void;
  97952. /**
  97953. * Restores the state of the stencil buffer
  97954. */
  97955. restoreStencilState(): void;
  97956. /**
  97957. * Directly set the WebGL Viewport
  97958. * @param x defines the x coordinate of the viewport (in screen space)
  97959. * @param y defines the y coordinate of the viewport (in screen space)
  97960. * @param width defines the width of the viewport (in screen space)
  97961. * @param height defines the height of the viewport (in screen space)
  97962. * @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
  97963. */
  97964. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  97965. /**
  97966. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  97967. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  97968. * @param y defines the y-coordinate of the corner of the clear rectangle
  97969. * @param width defines the width of the clear rectangle
  97970. * @param height defines the height of the clear rectangle
  97971. * @param clearColor defines the clear color
  97972. */
  97973. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  97974. /**
  97975. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  97976. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  97977. * @param y defines the y-coordinate of the corner of the clear rectangle
  97978. * @param width defines the width of the clear rectangle
  97979. * @param height defines the height of the clear rectangle
  97980. */
  97981. enableScissor(x: number, y: number, width: number, height: number): void;
  97982. /**
  97983. * Disable previously set scissor test rectangle
  97984. */
  97985. disableScissor(): void;
  97986. /**
  97987. * Initializes a webVR display and starts listening to display change events
  97988. * The onVRDisplayChangedObservable will be notified upon these changes
  97989. * @returns The onVRDisplayChangedObservable
  97990. */
  97991. initWebVR(): Observable<IDisplayChangedEventArgs>;
  97992. /** @hidden */
  97993. _prepareVRComponent(): void;
  97994. /** @hidden */
  97995. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  97996. /** @hidden */
  97997. _submitVRFrame(): void;
  97998. /**
  97999. * Call this function to leave webVR mode
  98000. * Will do nothing if webVR is not supported or if there is no webVR device
  98001. * @see http://doc.babylonjs.com/how_to/webvr_camera
  98002. */
  98003. disableVR(): void;
  98004. /**
  98005. * Gets a boolean indicating that the system is in VR mode and is presenting
  98006. * @returns true if VR mode is engaged
  98007. */
  98008. isVRPresenting(): boolean;
  98009. /** @hidden */
  98010. _requestVRFrame(): void;
  98011. /** @hidden */
  98012. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98013. /**
  98014. * Gets the source code of the vertex shader associated with a specific webGL program
  98015. * @param program defines the program to use
  98016. * @returns a string containing the source code of the vertex shader associated with the program
  98017. */
  98018. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  98019. /**
  98020. * Gets the source code of the fragment shader associated with a specific webGL program
  98021. * @param program defines the program to use
  98022. * @returns a string containing the source code of the fragment shader associated with the program
  98023. */
  98024. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  98025. /**
  98026. * Reads pixels from the current frame buffer. Please note that this function can be slow
  98027. * @param x defines the x coordinate of the rectangle where pixels must be read
  98028. * @param y defines the y coordinate of the rectangle where pixels must be read
  98029. * @param width defines the width of the rectangle where pixels must be read
  98030. * @param height defines the height of the rectangle where pixels must be read
  98031. * @returns a Uint8Array containing RGBA colors
  98032. */
  98033. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  98034. /**
  98035. * Sets a depth stencil texture from a render target to the according uniform.
  98036. * @param channel The texture channel
  98037. * @param uniform The uniform to set
  98038. * @param texture The render target texture containing the depth stencil texture to apply
  98039. */
  98040. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  98041. /**
  98042. * Sets a texture to the webGL context from a postprocess
  98043. * @param channel defines the channel to use
  98044. * @param postProcess defines the source postprocess
  98045. */
  98046. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  98047. /**
  98048. * Binds the output of the passed in post process to the texture channel specified
  98049. * @param channel The channel the texture should be bound to
  98050. * @param postProcess The post process which's output should be bound
  98051. */
  98052. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  98053. /** @hidden */
  98054. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  98055. protected _rebuildBuffers(): void;
  98056. _renderLoop(): void;
  98057. /**
  98058. * Toggle full screen mode
  98059. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98060. */
  98061. switchFullscreen(requestPointerLock: boolean): void;
  98062. /**
  98063. * Enters full screen mode
  98064. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98065. */
  98066. enterFullscreen(requestPointerLock: boolean): void;
  98067. /**
  98068. * Exits full screen mode
  98069. */
  98070. exitFullscreen(): void;
  98071. /**
  98072. * Enters Pointerlock mode
  98073. */
  98074. enterPointerlock(): void;
  98075. /**
  98076. * Exits Pointerlock mode
  98077. */
  98078. exitPointerlock(): void;
  98079. /**
  98080. * Begin a new frame
  98081. */
  98082. beginFrame(): void;
  98083. /**
  98084. * Enf the current frame
  98085. */
  98086. endFrame(): void;
  98087. resize(): void;
  98088. /**
  98089. * Set the compressed texture format to use, based on the formats you have, and the formats
  98090. * supported by the hardware / browser.
  98091. *
  98092. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  98093. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  98094. * to API arguments needed to compressed textures. This puts the burden on the container
  98095. * generator to house the arcane code for determining these for current & future formats.
  98096. *
  98097. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  98098. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  98099. *
  98100. * Note: The result of this call is not taken into account when a texture is base64.
  98101. *
  98102. * @param formatsAvailable defines the list of those format families you have created
  98103. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  98104. *
  98105. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  98106. * @returns The extension selected.
  98107. */
  98108. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  98109. /**
  98110. * Force a specific size of the canvas
  98111. * @param width defines the new canvas' width
  98112. * @param height defines the new canvas' height
  98113. */
  98114. setSize(width: number, height: number): void;
  98115. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98116. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98117. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98118. _releaseTexture(texture: InternalTexture): void;
  98119. /**
  98120. * @hidden
  98121. * Rescales a texture
  98122. * @param source input texutre
  98123. * @param destination destination texture
  98124. * @param scene scene to use to render the resize
  98125. * @param internalFormat format to use when resizing
  98126. * @param onComplete callback to be called when resize has completed
  98127. */
  98128. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98129. /**
  98130. * Gets the current framerate
  98131. * @returns a number representing the framerate
  98132. */
  98133. getFps(): number;
  98134. /**
  98135. * Gets the time spent between current and previous frame
  98136. * @returns a number representing the delta time in ms
  98137. */
  98138. getDeltaTime(): number;
  98139. private _measureFps;
  98140. /**
  98141. * Creates a new render target texture
  98142. * @param size defines the size of the texture
  98143. * @param options defines the options used to create the texture
  98144. * @returns a new render target texture stored in an InternalTexture
  98145. */
  98146. createRenderTargetTexture(size: number | {
  98147. width: number;
  98148. height: number;
  98149. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  98150. /**
  98151. * Updates the sample count of a render target texture
  98152. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  98153. * @param texture defines the texture to update
  98154. * @param samples defines the sample count to set
  98155. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  98156. */
  98157. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  98158. /** @hidden */
  98159. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  98160. dispose(): void;
  98161. private _disableTouchAction;
  98162. /**
  98163. * Display the loading screen
  98164. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98165. */
  98166. displayLoadingUI(): void;
  98167. /**
  98168. * Hide the loading screen
  98169. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98170. */
  98171. hideLoadingUI(): void;
  98172. /**
  98173. * Gets the current loading screen object
  98174. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98175. */
  98176. /**
  98177. * Sets the current loading screen object
  98178. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98179. */
  98180. loadingScreen: ILoadingScreen;
  98181. /**
  98182. * Sets the current loading screen text
  98183. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98184. */
  98185. loadingUIText: string;
  98186. /**
  98187. * Sets the current loading screen background color
  98188. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98189. */
  98190. loadingUIBackgroundColor: string;
  98191. /** Pointerlock and fullscreen */
  98192. /**
  98193. * Ask the browser to promote the current element to pointerlock mode
  98194. * @param element defines the DOM element to promote
  98195. */
  98196. static _RequestPointerlock(element: HTMLElement): void;
  98197. /**
  98198. * Asks the browser to exit pointerlock mode
  98199. */
  98200. static _ExitPointerlock(): void;
  98201. /**
  98202. * Ask the browser to promote the current element to fullscreen rendering mode
  98203. * @param element defines the DOM element to promote
  98204. */
  98205. static _RequestFullscreen(element: HTMLElement): void;
  98206. /**
  98207. * Asks the browser to exit fullscreen mode
  98208. */
  98209. static _ExitFullscreen(): void;
  98210. }
  98211. }
  98212. declare module BABYLON {
  98213. /**
  98214. * The engine store class is responsible to hold all the instances of Engine and Scene created
  98215. * during the life time of the application.
  98216. */
  98217. export class EngineStore {
  98218. /** Gets the list of created engines */
  98219. static Instances: Engine[];
  98220. /** @hidden */
  98221. static _LastCreatedScene: Nullable<Scene>;
  98222. /**
  98223. * Gets the latest created engine
  98224. */
  98225. static readonly LastCreatedEngine: Nullable<Engine>;
  98226. /**
  98227. * Gets the latest created scene
  98228. */
  98229. static readonly LastCreatedScene: Nullable<Scene>;
  98230. /**
  98231. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98232. * @ignorenaming
  98233. */
  98234. static UseFallbackTexture: boolean;
  98235. /**
  98236. * Texture content used if a texture cannot loaded
  98237. * @ignorenaming
  98238. */
  98239. static FallbackTexture: string;
  98240. }
  98241. }
  98242. declare module BABYLON {
  98243. /**
  98244. * Helper class that provides a small promise polyfill
  98245. */
  98246. export class PromisePolyfill {
  98247. /**
  98248. * Static function used to check if the polyfill is required
  98249. * If this is the case then the function will inject the polyfill to window.Promise
  98250. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  98251. */
  98252. static Apply(force?: boolean): void;
  98253. }
  98254. }
  98255. declare module BABYLON {
  98256. /**
  98257. * Interface for screenshot methods with describe argument called `size` as object with options
  98258. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  98259. */
  98260. export interface IScreenshotSize {
  98261. /**
  98262. * number in pixels for canvas height
  98263. */
  98264. height?: number;
  98265. /**
  98266. * multiplier allowing render at a higher or lower resolution
  98267. * If value is defined then height and width will be ignored and taken from camera
  98268. */
  98269. precision?: number;
  98270. /**
  98271. * number in pixels for canvas width
  98272. */
  98273. width?: number;
  98274. }
  98275. }
  98276. declare module BABYLON {
  98277. interface IColor4Like {
  98278. r: float;
  98279. g: float;
  98280. b: float;
  98281. a: float;
  98282. }
  98283. /**
  98284. * Class containing a set of static utilities functions
  98285. */
  98286. export class Tools {
  98287. /**
  98288. * Gets or sets the base URL to use to load assets
  98289. */
  98290. static BaseUrl: string;
  98291. /**
  98292. * Enable/Disable Custom HTTP Request Headers globally.
  98293. * default = false
  98294. * @see CustomRequestHeaders
  98295. */
  98296. static UseCustomRequestHeaders: boolean;
  98297. /**
  98298. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  98299. * i.e. when loading files, where the server/service expects an Authorization header
  98300. */
  98301. static CustomRequestHeaders: {
  98302. [key: string]: string;
  98303. };
  98304. /**
  98305. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  98306. */
  98307. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  98308. /**
  98309. * Default behaviour for cors in the application.
  98310. * It can be a string if the expected behavior is identical in the entire app.
  98311. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  98312. */
  98313. static CorsBehavior: string | ((url: string | string[]) => string);
  98314. /**
  98315. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98316. * @ignorenaming
  98317. */
  98318. static UseFallbackTexture: boolean;
  98319. /**
  98320. * Use this object to register external classes like custom textures or material
  98321. * to allow the laoders to instantiate them
  98322. */
  98323. static RegisteredExternalClasses: {
  98324. [key: string]: Object;
  98325. };
  98326. /**
  98327. * Texture content used if a texture cannot loaded
  98328. * @ignorenaming
  98329. */
  98330. static fallbackTexture: string;
  98331. /**
  98332. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  98333. * @param u defines the coordinate on X axis
  98334. * @param v defines the coordinate on Y axis
  98335. * @param width defines the width of the source data
  98336. * @param height defines the height of the source data
  98337. * @param pixels defines the source byte array
  98338. * @param color defines the output color
  98339. */
  98340. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  98341. /**
  98342. * Interpolates between a and b via alpha
  98343. * @param a The lower value (returned when alpha = 0)
  98344. * @param b The upper value (returned when alpha = 1)
  98345. * @param alpha The interpolation-factor
  98346. * @return The mixed value
  98347. */
  98348. static Mix(a: number, b: number, alpha: number): number;
  98349. /**
  98350. * Tries to instantiate a new object from a given class name
  98351. * @param className defines the class name to instantiate
  98352. * @returns the new object or null if the system was not able to do the instantiation
  98353. */
  98354. static Instantiate(className: string): any;
  98355. /**
  98356. * Provides a slice function that will work even on IE
  98357. * @param data defines the array to slice
  98358. * @param start defines the start of the data (optional)
  98359. * @param end defines the end of the data (optional)
  98360. * @returns the new sliced array
  98361. */
  98362. static Slice<T>(data: T, start?: number, end?: number): T;
  98363. /**
  98364. * Polyfill for setImmediate
  98365. * @param action defines the action to execute after the current execution block
  98366. */
  98367. static SetImmediate(action: () => void): void;
  98368. /**
  98369. * Function indicating if a number is an exponent of 2
  98370. * @param value defines the value to test
  98371. * @returns true if the value is an exponent of 2
  98372. */
  98373. static IsExponentOfTwo(value: number): boolean;
  98374. private static _tmpFloatArray;
  98375. /**
  98376. * Returns the nearest 32-bit single precision float representation of a Number
  98377. * @param value A Number. If the parameter is of a different type, it will get converted
  98378. * to a number or to NaN if it cannot be converted
  98379. * @returns number
  98380. */
  98381. static FloatRound(value: number): number;
  98382. /**
  98383. * Extracts the filename from a path
  98384. * @param path defines the path to use
  98385. * @returns the filename
  98386. */
  98387. static GetFilename(path: string): string;
  98388. /**
  98389. * Extracts the "folder" part of a path (everything before the filename).
  98390. * @param uri The URI to extract the info from
  98391. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  98392. * @returns The "folder" part of the path
  98393. */
  98394. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  98395. /**
  98396. * Extracts text content from a DOM element hierarchy
  98397. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  98398. */
  98399. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  98400. /**
  98401. * Convert an angle in radians to degrees
  98402. * @param angle defines the angle to convert
  98403. * @returns the angle in degrees
  98404. */
  98405. static ToDegrees(angle: number): number;
  98406. /**
  98407. * Convert an angle in degrees to radians
  98408. * @param angle defines the angle to convert
  98409. * @returns the angle in radians
  98410. */
  98411. static ToRadians(angle: number): number;
  98412. /**
  98413. * Encode a buffer to a base64 string
  98414. * @param buffer defines the buffer to encode
  98415. * @returns the encoded string
  98416. */
  98417. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  98418. /**
  98419. * Returns an array if obj is not an array
  98420. * @param obj defines the object to evaluate as an array
  98421. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  98422. * @returns either obj directly if obj is an array or a new array containing obj
  98423. */
  98424. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  98425. /**
  98426. * Gets the pointer prefix to use
  98427. * @returns "pointer" if touch is enabled. Else returns "mouse"
  98428. */
  98429. static GetPointerPrefix(): string;
  98430. /**
  98431. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  98432. * @param url define the url we are trying
  98433. * @param element define the dom element where to configure the cors policy
  98434. */
  98435. static SetCorsBehavior(url: string | string[], element: {
  98436. crossOrigin: string | null;
  98437. }): void;
  98438. /**
  98439. * Removes unwanted characters from an url
  98440. * @param url defines the url to clean
  98441. * @returns the cleaned url
  98442. */
  98443. static CleanUrl(url: string): string;
  98444. /**
  98445. * Gets or sets a function used to pre-process url before using them to load assets
  98446. */
  98447. static PreprocessUrl: (url: string) => string;
  98448. /**
  98449. * Loads an image as an HTMLImageElement.
  98450. * @param input url string, ArrayBuffer, or Blob to load
  98451. * @param onLoad callback called when the image successfully loads
  98452. * @param onError callback called when the image fails to load
  98453. * @param offlineProvider offline provider for caching
  98454. * @returns the HTMLImageElement of the loaded image
  98455. */
  98456. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  98457. /**
  98458. * Loads a file
  98459. * @param url url string, ArrayBuffer, or Blob to load
  98460. * @param onSuccess callback called when the file successfully loads
  98461. * @param onProgress callback called while file is loading (if the server supports this mode)
  98462. * @param offlineProvider defines the offline provider for caching
  98463. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  98464. * @param onError callback called when the file fails to load
  98465. * @returns a file request object
  98466. */
  98467. 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;
  98468. /**
  98469. * Loads a file from a url
  98470. * @param url the file url to load
  98471. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  98472. */
  98473. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  98474. /**
  98475. * Load a script (identified by an url). When the url returns, the
  98476. * content of this file is added into a new script element, attached to the DOM (body element)
  98477. * @param scriptUrl defines the url of the script to laod
  98478. * @param onSuccess defines the callback called when the script is loaded
  98479. * @param onError defines the callback to call if an error occurs
  98480. * @param scriptId defines the id of the script element
  98481. */
  98482. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  98483. /**
  98484. * Load an asynchronous script (identified by an url). When the url returns, the
  98485. * content of this file is added into a new script element, attached to the DOM (body element)
  98486. * @param scriptUrl defines the url of the script to laod
  98487. * @param scriptId defines the id of the script element
  98488. * @returns a promise request object
  98489. */
  98490. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  98491. /**
  98492. * Loads a file from a blob
  98493. * @param fileToLoad defines the blob to use
  98494. * @param callback defines the callback to call when data is loaded
  98495. * @param progressCallback defines the callback to call during loading process
  98496. * @returns a file request object
  98497. */
  98498. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  98499. /**
  98500. * Loads a file
  98501. * @param fileToLoad defines the file to load
  98502. * @param callback defines the callback to call when data is loaded
  98503. * @param progressCallBack defines the callback to call during loading process
  98504. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  98505. * @returns a file request object
  98506. */
  98507. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  98508. /**
  98509. * Creates a data url from a given string content
  98510. * @param content defines the content to convert
  98511. * @returns the new data url link
  98512. */
  98513. static FileAsURL(content: string): string;
  98514. /**
  98515. * Format the given number to a specific decimal format
  98516. * @param value defines the number to format
  98517. * @param decimals defines the number of decimals to use
  98518. * @returns the formatted string
  98519. */
  98520. static Format(value: number, decimals?: number): string;
  98521. /**
  98522. * Tries to copy an object by duplicating every property
  98523. * @param source defines the source object
  98524. * @param destination defines the target object
  98525. * @param doNotCopyList defines a list of properties to avoid
  98526. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98527. */
  98528. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  98529. /**
  98530. * Gets a boolean indicating if the given object has no own property
  98531. * @param obj defines the object to test
  98532. * @returns true if object has no own property
  98533. */
  98534. static IsEmpty(obj: any): boolean;
  98535. /**
  98536. * Function used to register events at window level
  98537. * @param windowElement defines the Window object to use
  98538. * @param events defines the events to register
  98539. */
  98540. static RegisterTopRootEvents(windowElement: Window, events: {
  98541. name: string;
  98542. handler: Nullable<(e: FocusEvent) => any>;
  98543. }[]): void;
  98544. /**
  98545. * Function used to unregister events from window level
  98546. * @param windowElement defines the Window object to use
  98547. * @param events defines the events to unregister
  98548. */
  98549. static UnregisterTopRootEvents(windowElement: Window, events: {
  98550. name: string;
  98551. handler: Nullable<(e: FocusEvent) => any>;
  98552. }[]): void;
  98553. /**
  98554. * @ignore
  98555. */
  98556. static _ScreenshotCanvas: HTMLCanvasElement;
  98557. /**
  98558. * Dumps the current bound framebuffer
  98559. * @param width defines the rendering width
  98560. * @param height defines the rendering height
  98561. * @param engine defines the hosting engine
  98562. * @param successCallback defines the callback triggered once the data are available
  98563. * @param mimeType defines the mime type of the result
  98564. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  98565. */
  98566. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98567. /**
  98568. * Converts the canvas data to blob.
  98569. * This acts as a polyfill for browsers not supporting the to blob function.
  98570. * @param canvas Defines the canvas to extract the data from
  98571. * @param successCallback Defines the callback triggered once the data are available
  98572. * @param mimeType Defines the mime type of the result
  98573. */
  98574. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  98575. /**
  98576. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  98577. * @param successCallback defines the callback triggered once the data are available
  98578. * @param mimeType defines the mime type of the result
  98579. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  98580. */
  98581. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98582. /**
  98583. * Downloads a blob in the browser
  98584. * @param blob defines the blob to download
  98585. * @param fileName defines the name of the downloaded file
  98586. */
  98587. static Download(blob: Blob, fileName: string): void;
  98588. /**
  98589. * Captures a screenshot of the current rendering
  98590. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98591. * @param engine defines the rendering engine
  98592. * @param camera defines the source camera
  98593. * @param size This parameter can be set to a single number or to an object with the
  98594. * following (optional) properties: precision, width, height. If a single number is passed,
  98595. * it will be used for both width and height. If an object is passed, the screenshot size
  98596. * will be derived from the parameters. The precision property is a multiplier allowing
  98597. * rendering at a higher or lower resolution
  98598. * @param successCallback defines the callback receives a single parameter which contains the
  98599. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98600. * src parameter of an <img> to display it
  98601. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98602. * Check your browser for supported MIME types
  98603. */
  98604. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  98605. /**
  98606. * Captures a screenshot of the current rendering
  98607. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98608. * @param engine defines the rendering engine
  98609. * @param camera defines the source camera
  98610. * @param size This parameter can be set to a single number or to an object with the
  98611. * following (optional) properties: precision, width, height. If a single number is passed,
  98612. * it will be used for both width and height. If an object is passed, the screenshot size
  98613. * will be derived from the parameters. The precision property is a multiplier allowing
  98614. * rendering at a higher or lower resolution
  98615. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98616. * Check your browser for supported MIME types
  98617. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  98618. * to the src parameter of an <img> to display it
  98619. */
  98620. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  98621. /**
  98622. * Generates an image screenshot from the specified camera.
  98623. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98624. * @param engine The engine to use for rendering
  98625. * @param camera The camera to use for rendering
  98626. * @param size This parameter can be set to a single number or to an object with the
  98627. * following (optional) properties: precision, width, height. If a single number is passed,
  98628. * it will be used for both width and height. If an object is passed, the screenshot size
  98629. * will be derived from the parameters. The precision property is a multiplier allowing
  98630. * rendering at a higher or lower resolution
  98631. * @param successCallback The callback receives a single parameter which contains the
  98632. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98633. * src parameter of an <img> to display it
  98634. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98635. * Check your browser for supported MIME types
  98636. * @param samples Texture samples (default: 1)
  98637. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98638. * @param fileName A name for for the downloaded file.
  98639. */
  98640. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  98641. /**
  98642. * Generates an image screenshot from the specified camera.
  98643. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98644. * @param engine The engine to use for rendering
  98645. * @param camera The camera to use for rendering
  98646. * @param size This parameter can be set to a single number or to an object with the
  98647. * following (optional) properties: precision, width, height. If a single number is passed,
  98648. * it will be used for both width and height. If an object is passed, the screenshot size
  98649. * will be derived from the parameters. The precision property is a multiplier allowing
  98650. * rendering at a higher or lower resolution
  98651. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98652. * Check your browser for supported MIME types
  98653. * @param samples Texture samples (default: 1)
  98654. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98655. * @param fileName A name for for the downloaded file.
  98656. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  98657. * to the src parameter of an <img> to display it
  98658. */
  98659. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  98660. /**
  98661. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98662. * Be aware Math.random() could cause collisions, but:
  98663. * "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"
  98664. * @returns a pseudo random id
  98665. */
  98666. static RandomId(): string;
  98667. /**
  98668. * Test if the given uri is a base64 string
  98669. * @param uri The uri to test
  98670. * @return True if the uri is a base64 string or false otherwise
  98671. */
  98672. static IsBase64(uri: string): boolean;
  98673. /**
  98674. * Decode the given base64 uri.
  98675. * @param uri The uri to decode
  98676. * @return The decoded base64 data.
  98677. */
  98678. static DecodeBase64(uri: string): ArrayBuffer;
  98679. /**
  98680. * Gets the absolute url.
  98681. * @param url the input url
  98682. * @return the absolute url
  98683. */
  98684. static GetAbsoluteUrl(url: string): string;
  98685. /**
  98686. * No log
  98687. */
  98688. static readonly NoneLogLevel: number;
  98689. /**
  98690. * Only message logs
  98691. */
  98692. static readonly MessageLogLevel: number;
  98693. /**
  98694. * Only warning logs
  98695. */
  98696. static readonly WarningLogLevel: number;
  98697. /**
  98698. * Only error logs
  98699. */
  98700. static readonly ErrorLogLevel: number;
  98701. /**
  98702. * All logs
  98703. */
  98704. static readonly AllLogLevel: number;
  98705. /**
  98706. * Gets a value indicating the number of loading errors
  98707. * @ignorenaming
  98708. */
  98709. static readonly errorsCount: number;
  98710. /**
  98711. * Callback called when a new log is added
  98712. */
  98713. static OnNewCacheEntry: (entry: string) => void;
  98714. /**
  98715. * Log a message to the console
  98716. * @param message defines the message to log
  98717. */
  98718. static Log(message: string): void;
  98719. /**
  98720. * Write a warning message to the console
  98721. * @param message defines the message to log
  98722. */
  98723. static Warn(message: string): void;
  98724. /**
  98725. * Write an error message to the console
  98726. * @param message defines the message to log
  98727. */
  98728. static Error(message: string): void;
  98729. /**
  98730. * Gets current log cache (list of logs)
  98731. */
  98732. static readonly LogCache: string;
  98733. /**
  98734. * Clears the log cache
  98735. */
  98736. static ClearLogCache(): void;
  98737. /**
  98738. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  98739. */
  98740. static LogLevels: number;
  98741. /**
  98742. * Checks if the window object exists
  98743. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  98744. */
  98745. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  98746. /**
  98747. * No performance log
  98748. */
  98749. static readonly PerformanceNoneLogLevel: number;
  98750. /**
  98751. * Use user marks to log performance
  98752. */
  98753. static readonly PerformanceUserMarkLogLevel: number;
  98754. /**
  98755. * Log performance to the console
  98756. */
  98757. static readonly PerformanceConsoleLogLevel: number;
  98758. private static _performance;
  98759. /**
  98760. * Sets the current performance log level
  98761. */
  98762. static PerformanceLogLevel: number;
  98763. private static _StartPerformanceCounterDisabled;
  98764. private static _EndPerformanceCounterDisabled;
  98765. private static _StartUserMark;
  98766. private static _EndUserMark;
  98767. private static _StartPerformanceConsole;
  98768. private static _EndPerformanceConsole;
  98769. /**
  98770. * Starts a performance counter
  98771. */
  98772. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98773. /**
  98774. * Ends a specific performance coutner
  98775. */
  98776. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98777. /**
  98778. * Gets either window.performance.now() if supported or Date.now() else
  98779. */
  98780. static readonly Now: number;
  98781. /**
  98782. * This method will return the name of the class used to create the instance of the given object.
  98783. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  98784. * @param object the object to get the class name from
  98785. * @param isType defines if the object is actually a type
  98786. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  98787. */
  98788. static GetClassName(object: any, isType?: boolean): string;
  98789. /**
  98790. * Gets the first element of an array satisfying a given predicate
  98791. * @param array defines the array to browse
  98792. * @param predicate defines the predicate to use
  98793. * @returns null if not found or the element
  98794. */
  98795. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  98796. /**
  98797. * This method will return the name of the full name of the class, including its owning module (if any).
  98798. * 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).
  98799. * @param object the object to get the class name from
  98800. * @param isType defines if the object is actually a type
  98801. * @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.
  98802. * @ignorenaming
  98803. */
  98804. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  98805. /**
  98806. * Returns a promise that resolves after the given amount of time.
  98807. * @param delay Number of milliseconds to delay
  98808. * @returns Promise that resolves after the given amount of time
  98809. */
  98810. static DelayAsync(delay: number): Promise<void>;
  98811. }
  98812. /**
  98813. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  98814. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  98815. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  98816. * @param name The name of the class, case should be preserved
  98817. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  98818. */
  98819. export function className(name: string, module?: string): (target: Object) => void;
  98820. /**
  98821. * An implementation of a loop for asynchronous functions.
  98822. */
  98823. export class AsyncLoop {
  98824. /**
  98825. * Defines the number of iterations for the loop
  98826. */
  98827. iterations: number;
  98828. /**
  98829. * Defines the current index of the loop.
  98830. */
  98831. index: number;
  98832. private _done;
  98833. private _fn;
  98834. private _successCallback;
  98835. /**
  98836. * Constructor.
  98837. * @param iterations the number of iterations.
  98838. * @param func the function to run each iteration
  98839. * @param successCallback the callback that will be called upon succesful execution
  98840. * @param offset starting offset.
  98841. */
  98842. constructor(
  98843. /**
  98844. * Defines the number of iterations for the loop
  98845. */
  98846. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  98847. /**
  98848. * Execute the next iteration. Must be called after the last iteration was finished.
  98849. */
  98850. executeNext(): void;
  98851. /**
  98852. * Break the loop and run the success callback.
  98853. */
  98854. breakLoop(): void;
  98855. /**
  98856. * Create and run an async loop.
  98857. * @param iterations the number of iterations.
  98858. * @param fn the function to run each iteration
  98859. * @param successCallback the callback that will be called upon succesful execution
  98860. * @param offset starting offset.
  98861. * @returns the created async loop object
  98862. */
  98863. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  98864. /**
  98865. * A for-loop that will run a given number of iterations synchronous and the rest async.
  98866. * @param iterations total number of iterations
  98867. * @param syncedIterations number of synchronous iterations in each async iteration.
  98868. * @param fn the function to call each iteration.
  98869. * @param callback a success call back that will be called when iterating stops.
  98870. * @param breakFunction a break condition (optional)
  98871. * @param timeout timeout settings for the setTimeout function. default - 0.
  98872. * @returns the created async loop object
  98873. */
  98874. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  98875. }
  98876. }
  98877. declare module BABYLON {
  98878. /**
  98879. * This class implement a typical dictionary using a string as key and the generic type T as value.
  98880. * The underlying implementation relies on an associative array to ensure the best performances.
  98881. * The value can be anything including 'null' but except 'undefined'
  98882. */
  98883. export class StringDictionary<T> {
  98884. /**
  98885. * This will clear this dictionary and copy the content from the 'source' one.
  98886. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  98887. * @param source the dictionary to take the content from and copy to this dictionary
  98888. */
  98889. copyFrom(source: StringDictionary<T>): void;
  98890. /**
  98891. * Get a value based from its key
  98892. * @param key the given key to get the matching value from
  98893. * @return the value if found, otherwise undefined is returned
  98894. */
  98895. get(key: string): T | undefined;
  98896. /**
  98897. * Get a value from its key or add it if it doesn't exist.
  98898. * This method will ensure you that a given key/data will be present in the dictionary.
  98899. * @param key the given key to get the matching value from
  98900. * @param factory the factory that will create the value if the key is not present in the dictionary.
  98901. * The factory will only be invoked if there's no data for the given key.
  98902. * @return the value corresponding to the key.
  98903. */
  98904. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  98905. /**
  98906. * Get a value from its key if present in the dictionary otherwise add it
  98907. * @param key the key to get the value from
  98908. * @param val if there's no such key/value pair in the dictionary add it with this value
  98909. * @return the value corresponding to the key
  98910. */
  98911. getOrAdd(key: string, val: T): T;
  98912. /**
  98913. * Check if there's a given key in the dictionary
  98914. * @param key the key to check for
  98915. * @return true if the key is present, false otherwise
  98916. */
  98917. contains(key: string): boolean;
  98918. /**
  98919. * Add a new key and its corresponding value
  98920. * @param key the key to add
  98921. * @param value the value corresponding to the key
  98922. * @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
  98923. */
  98924. add(key: string, value: T): boolean;
  98925. /**
  98926. * Update a specific value associated to a key
  98927. * @param key defines the key to use
  98928. * @param value defines the value to store
  98929. * @returns true if the value was updated (or false if the key was not found)
  98930. */
  98931. set(key: string, value: T): boolean;
  98932. /**
  98933. * Get the element of the given key and remove it from the dictionary
  98934. * @param key defines the key to search
  98935. * @returns the value associated with the key or null if not found
  98936. */
  98937. getAndRemove(key: string): Nullable<T>;
  98938. /**
  98939. * Remove a key/value from the dictionary.
  98940. * @param key the key to remove
  98941. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  98942. */
  98943. remove(key: string): boolean;
  98944. /**
  98945. * Clear the whole content of the dictionary
  98946. */
  98947. clear(): void;
  98948. /**
  98949. * Gets the current count
  98950. */
  98951. readonly count: number;
  98952. /**
  98953. * Execute a callback on each key/val of the dictionary.
  98954. * Note that you can remove any element in this dictionary in the callback implementation
  98955. * @param callback the callback to execute on a given key/value pair
  98956. */
  98957. forEach(callback: (key: string, val: T) => void): void;
  98958. /**
  98959. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  98960. * If the callback returns null or undefined the method will iterate to the next key/value pair
  98961. * Note that you can remove any element in this dictionary in the callback implementation
  98962. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  98963. * @returns the first item
  98964. */
  98965. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  98966. private _count;
  98967. private _data;
  98968. }
  98969. }
  98970. declare module BABYLON {
  98971. /** @hidden */
  98972. export interface ICollisionCoordinator {
  98973. createCollider(): Collider;
  98974. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98975. init(scene: Scene): void;
  98976. }
  98977. /** @hidden */
  98978. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  98979. private _scene;
  98980. private _scaledPosition;
  98981. private _scaledVelocity;
  98982. private _finalPosition;
  98983. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98984. createCollider(): Collider;
  98985. init(scene: Scene): void;
  98986. private _collideWithWorld;
  98987. }
  98988. }
  98989. declare module BABYLON {
  98990. /**
  98991. * Class used to manage all inputs for the scene.
  98992. */
  98993. export class InputManager {
  98994. /** The distance in pixel that you have to move to prevent some events */
  98995. static DragMovementThreshold: number;
  98996. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  98997. static LongPressDelay: number;
  98998. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  98999. static DoubleClickDelay: number;
  99000. /** If you need to check double click without raising a single click at first click, enable this flag */
  99001. static ExclusiveDoubleClickMode: boolean;
  99002. private _wheelEventName;
  99003. private _onPointerMove;
  99004. private _onPointerDown;
  99005. private _onPointerUp;
  99006. private _initClickEvent;
  99007. private _initActionManager;
  99008. private _delayedSimpleClick;
  99009. private _delayedSimpleClickTimeout;
  99010. private _previousDelayedSimpleClickTimeout;
  99011. private _meshPickProceed;
  99012. private _previousButtonPressed;
  99013. private _currentPickResult;
  99014. private _previousPickResult;
  99015. private _totalPointersPressed;
  99016. private _doubleClickOccured;
  99017. private _pointerOverMesh;
  99018. private _pickedDownMesh;
  99019. private _pickedUpMesh;
  99020. private _pointerX;
  99021. private _pointerY;
  99022. private _unTranslatedPointerX;
  99023. private _unTranslatedPointerY;
  99024. private _startingPointerPosition;
  99025. private _previousStartingPointerPosition;
  99026. private _startingPointerTime;
  99027. private _previousStartingPointerTime;
  99028. private _pointerCaptures;
  99029. private _onKeyDown;
  99030. private _onKeyUp;
  99031. private _onCanvasFocusObserver;
  99032. private _onCanvasBlurObserver;
  99033. private _scene;
  99034. /**
  99035. * Creates a new InputManager
  99036. * @param scene defines the hosting scene
  99037. */
  99038. constructor(scene: Scene);
  99039. /**
  99040. * Gets the mesh that is currently under the pointer
  99041. */
  99042. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99043. /**
  99044. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  99045. */
  99046. readonly unTranslatedPointer: Vector2;
  99047. /**
  99048. * Gets or sets the current on-screen X position of the pointer
  99049. */
  99050. pointerX: number;
  99051. /**
  99052. * Gets or sets the current on-screen Y position of the pointer
  99053. */
  99054. pointerY: number;
  99055. private _updatePointerPosition;
  99056. private _processPointerMove;
  99057. private _setRayOnPointerInfo;
  99058. private _checkPrePointerObservable;
  99059. /**
  99060. * Use this method to simulate a pointer move on a mesh
  99061. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99062. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99063. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99064. */
  99065. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99066. /**
  99067. * Use this method to simulate a pointer down on a mesh
  99068. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99069. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99070. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99071. */
  99072. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99073. private _processPointerDown;
  99074. /** @hidden */
  99075. _isPointerSwiping(): boolean;
  99076. /**
  99077. * Use this method to simulate a pointer up on a mesh
  99078. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99079. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99080. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99081. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99082. */
  99083. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  99084. private _processPointerUp;
  99085. /**
  99086. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99087. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99088. * @returns true if the pointer was captured
  99089. */
  99090. isPointerCaptured(pointerId?: number): boolean;
  99091. /**
  99092. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99093. * @param attachUp defines if you want to attach events to pointerup
  99094. * @param attachDown defines if you want to attach events to pointerdown
  99095. * @param attachMove defines if you want to attach events to pointermove
  99096. */
  99097. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99098. /**
  99099. * Detaches all event handlers
  99100. */
  99101. detachControl(): void;
  99102. /**
  99103. * Force the value of meshUnderPointer
  99104. * @param mesh defines the mesh to use
  99105. */
  99106. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99107. /**
  99108. * Gets the mesh under the pointer
  99109. * @returns a Mesh or null if no mesh is under the pointer
  99110. */
  99111. getPointerOverMesh(): Nullable<AbstractMesh>;
  99112. }
  99113. }
  99114. declare module BABYLON {
  99115. /**
  99116. * Helper class used to generate session unique ID
  99117. */
  99118. export class UniqueIdGenerator {
  99119. private static _UniqueIdCounter;
  99120. /**
  99121. * Gets an unique (relatively to the current scene) Id
  99122. */
  99123. static readonly UniqueId: number;
  99124. }
  99125. }
  99126. declare module BABYLON {
  99127. /**
  99128. * This class defines the direct association between an animation and a target
  99129. */
  99130. export class TargetedAnimation {
  99131. /**
  99132. * Animation to perform
  99133. */
  99134. animation: Animation;
  99135. /**
  99136. * Target to animate
  99137. */
  99138. target: any;
  99139. /**
  99140. * Serialize the object
  99141. * @returns the JSON object representing the current entity
  99142. */
  99143. serialize(): any;
  99144. }
  99145. /**
  99146. * Use this class to create coordinated animations on multiple targets
  99147. */
  99148. export class AnimationGroup implements IDisposable {
  99149. /** The name of the animation group */
  99150. name: string;
  99151. private _scene;
  99152. private _targetedAnimations;
  99153. private _animatables;
  99154. private _from;
  99155. private _to;
  99156. private _isStarted;
  99157. private _isPaused;
  99158. private _speedRatio;
  99159. private _loopAnimation;
  99160. /**
  99161. * Gets or sets the unique id of the node
  99162. */
  99163. uniqueId: number;
  99164. /**
  99165. * This observable will notify when one animation have ended
  99166. */
  99167. onAnimationEndObservable: Observable<TargetedAnimation>;
  99168. /**
  99169. * Observer raised when one animation loops
  99170. */
  99171. onAnimationLoopObservable: Observable<TargetedAnimation>;
  99172. /**
  99173. * This observable will notify when all animations have ended.
  99174. */
  99175. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  99176. /**
  99177. * This observable will notify when all animations have paused.
  99178. */
  99179. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  99180. /**
  99181. * This observable will notify when all animations are playing.
  99182. */
  99183. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  99184. /**
  99185. * Gets the first frame
  99186. */
  99187. readonly from: number;
  99188. /**
  99189. * Gets the last frame
  99190. */
  99191. readonly to: number;
  99192. /**
  99193. * Define if the animations are started
  99194. */
  99195. readonly isStarted: boolean;
  99196. /**
  99197. * Gets a value indicating that the current group is playing
  99198. */
  99199. readonly isPlaying: boolean;
  99200. /**
  99201. * Gets or sets the speed ratio to use for all animations
  99202. */
  99203. /**
  99204. * Gets or sets the speed ratio to use for all animations
  99205. */
  99206. speedRatio: number;
  99207. /**
  99208. * Gets or sets if all animations should loop or not
  99209. */
  99210. loopAnimation: boolean;
  99211. /**
  99212. * Gets the targeted animations for this animation group
  99213. */
  99214. readonly targetedAnimations: Array<TargetedAnimation>;
  99215. /**
  99216. * returning the list of animatables controlled by this animation group.
  99217. */
  99218. readonly animatables: Array<Animatable>;
  99219. /**
  99220. * Instantiates a new Animation Group.
  99221. * This helps managing several animations at once.
  99222. * @see http://doc.babylonjs.com/how_to/group
  99223. * @param name Defines the name of the group
  99224. * @param scene Defines the scene the group belongs to
  99225. */
  99226. constructor(
  99227. /** The name of the animation group */
  99228. name: string, scene?: Nullable<Scene>);
  99229. /**
  99230. * Add an animation (with its target) in the group
  99231. * @param animation defines the animation we want to add
  99232. * @param target defines the target of the animation
  99233. * @returns the TargetedAnimation object
  99234. */
  99235. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  99236. /**
  99237. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  99238. * It can add constant keys at begin or end
  99239. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  99240. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  99241. * @returns the animation group
  99242. */
  99243. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  99244. /**
  99245. * Start all animations on given targets
  99246. * @param loop defines if animations must loop
  99247. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  99248. * @param from defines the from key (optional)
  99249. * @param to defines the to key (optional)
  99250. * @returns the current animation group
  99251. */
  99252. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  99253. /**
  99254. * Pause all animations
  99255. * @returns the animation group
  99256. */
  99257. pause(): AnimationGroup;
  99258. /**
  99259. * Play all animations to initial state
  99260. * This function will start() the animations if they were not started or will restart() them if they were paused
  99261. * @param loop defines if animations must loop
  99262. * @returns the animation group
  99263. */
  99264. play(loop?: boolean): AnimationGroup;
  99265. /**
  99266. * Reset all animations to initial state
  99267. * @returns the animation group
  99268. */
  99269. reset(): AnimationGroup;
  99270. /**
  99271. * Restart animations from key 0
  99272. * @returns the animation group
  99273. */
  99274. restart(): AnimationGroup;
  99275. /**
  99276. * Stop all animations
  99277. * @returns the animation group
  99278. */
  99279. stop(): AnimationGroup;
  99280. /**
  99281. * Set animation weight for all animatables
  99282. * @param weight defines the weight to use
  99283. * @return the animationGroup
  99284. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99285. */
  99286. setWeightForAllAnimatables(weight: number): AnimationGroup;
  99287. /**
  99288. * Synchronize and normalize all animatables with a source animatable
  99289. * @param root defines the root animatable to synchronize with
  99290. * @return the animationGroup
  99291. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99292. */
  99293. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  99294. /**
  99295. * Goes to a specific frame in this animation group
  99296. * @param frame the frame number to go to
  99297. * @return the animationGroup
  99298. */
  99299. goToFrame(frame: number): AnimationGroup;
  99300. /**
  99301. * Dispose all associated resources
  99302. */
  99303. dispose(): void;
  99304. private _checkAnimationGroupEnded;
  99305. /**
  99306. * Clone the current animation group and returns a copy
  99307. * @param newName defines the name of the new group
  99308. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  99309. * @returns the new aniamtion group
  99310. */
  99311. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  99312. /**
  99313. * Serializes the animationGroup to an object
  99314. * @returns Serialized object
  99315. */
  99316. serialize(): any;
  99317. /**
  99318. * Returns a new AnimationGroup object parsed from the source provided.
  99319. * @param parsedAnimationGroup defines the source
  99320. * @param scene defines the scene that will receive the animationGroup
  99321. * @returns a new AnimationGroup
  99322. */
  99323. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  99324. /**
  99325. * Returns the string "AnimationGroup"
  99326. * @returns "AnimationGroup"
  99327. */
  99328. getClassName(): string;
  99329. /**
  99330. * Creates a detailled string about the object
  99331. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  99332. * @returns a string representing the object
  99333. */
  99334. toString(fullDetails?: boolean): string;
  99335. }
  99336. }
  99337. declare module BABYLON {
  99338. /**
  99339. * Define an interface for all classes that will hold resources
  99340. */
  99341. export interface IDisposable {
  99342. /**
  99343. * Releases all held resources
  99344. */
  99345. dispose(): void;
  99346. }
  99347. /** Interface defining initialization parameters for Scene class */
  99348. export interface SceneOptions {
  99349. /**
  99350. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  99351. * It will improve performance when the number of geometries becomes important.
  99352. */
  99353. useGeometryUniqueIdsMap?: boolean;
  99354. /**
  99355. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  99356. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99357. */
  99358. useMaterialMeshMap?: boolean;
  99359. /**
  99360. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  99361. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99362. */
  99363. useClonedMeshhMap?: boolean;
  99364. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  99365. virtual?: boolean;
  99366. }
  99367. /**
  99368. * Represents a scene to be rendered by the engine.
  99369. * @see http://doc.babylonjs.com/features/scene
  99370. */
  99371. export class Scene extends AbstractScene implements IAnimatable {
  99372. /** The fog is deactivated */
  99373. static readonly FOGMODE_NONE: number;
  99374. /** The fog density is following an exponential function */
  99375. static readonly FOGMODE_EXP: number;
  99376. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  99377. static readonly FOGMODE_EXP2: number;
  99378. /** The fog density is following a linear function. */
  99379. static readonly FOGMODE_LINEAR: number;
  99380. /**
  99381. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  99382. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99383. */
  99384. static MinDeltaTime: number;
  99385. /**
  99386. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  99387. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99388. */
  99389. static MaxDeltaTime: number;
  99390. /**
  99391. * Factory used to create the default material.
  99392. * @param name The name of the material to create
  99393. * @param scene The scene to create the material for
  99394. * @returns The default material
  99395. */
  99396. static DefaultMaterialFactory(scene: Scene): Material;
  99397. /**
  99398. * Factory used to create the a collision coordinator.
  99399. * @returns The collision coordinator
  99400. */
  99401. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  99402. /** @hidden */
  99403. _inputManager: InputManager;
  99404. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  99405. cameraToUseForPointers: Nullable<Camera>;
  99406. /** @hidden */
  99407. readonly _isScene: boolean;
  99408. /**
  99409. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  99410. */
  99411. autoClear: boolean;
  99412. /**
  99413. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  99414. */
  99415. autoClearDepthAndStencil: boolean;
  99416. /**
  99417. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  99418. */
  99419. clearColor: Color4;
  99420. /**
  99421. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  99422. */
  99423. ambientColor: Color3;
  99424. /**
  99425. * This is use to store the default BRDF lookup for PBR materials in your scene.
  99426. * It should only be one of the following (if not the default embedded one):
  99427. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  99428. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  99429. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  99430. * The material properties need to be setup according to the type of texture in use.
  99431. */
  99432. environmentBRDFTexture: BaseTexture;
  99433. /** @hidden */
  99434. protected _environmentTexture: Nullable<BaseTexture>;
  99435. /**
  99436. * Texture used in all pbr material as the reflection texture.
  99437. * As in the majority of the scene they are the same (exception for multi room and so on),
  99438. * this is easier to reference from here than from all the materials.
  99439. */
  99440. /**
  99441. * Texture used in all pbr material as the reflection texture.
  99442. * As in the majority of the scene they are the same (exception for multi room and so on),
  99443. * this is easier to set here than in all the materials.
  99444. */
  99445. environmentTexture: Nullable<BaseTexture>;
  99446. /** @hidden */
  99447. protected _environmentIntensity: number;
  99448. /**
  99449. * Intensity of the environment in all pbr material.
  99450. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  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. * Intensity of the environment in all pbr material.
  99456. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99457. * As in the majority of the scene they are the same (exception for multi room and so on),
  99458. * this is easier to set here than in all the materials.
  99459. */
  99460. environmentIntensity: number;
  99461. /** @hidden */
  99462. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99463. /**
  99464. * Default image processing configuration used either in the rendering
  99465. * Forward main pass or through the imageProcessingPostProcess if present.
  99466. * As in the majority of the scene they are the same (exception for multi camera),
  99467. * this is easier to reference from here than from all the materials and post process.
  99468. *
  99469. * No setter as we it is a shared configuration, you can set the values instead.
  99470. */
  99471. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  99472. private _forceWireframe;
  99473. /**
  99474. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  99475. */
  99476. forceWireframe: boolean;
  99477. private _forcePointsCloud;
  99478. /**
  99479. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  99480. */
  99481. forcePointsCloud: boolean;
  99482. /**
  99483. * Gets or sets the active clipplane 1
  99484. */
  99485. clipPlane: Nullable<Plane>;
  99486. /**
  99487. * Gets or sets the active clipplane 2
  99488. */
  99489. clipPlane2: Nullable<Plane>;
  99490. /**
  99491. * Gets or sets the active clipplane 3
  99492. */
  99493. clipPlane3: Nullable<Plane>;
  99494. /**
  99495. * Gets or sets the active clipplane 4
  99496. */
  99497. clipPlane4: Nullable<Plane>;
  99498. /**
  99499. * Gets or sets a boolean indicating if animations are enabled
  99500. */
  99501. animationsEnabled: boolean;
  99502. private _animationPropertiesOverride;
  99503. /**
  99504. * Gets or sets the animation properties override
  99505. */
  99506. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  99507. /**
  99508. * Gets or sets a boolean indicating if a constant deltatime has to be used
  99509. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  99510. */
  99511. useConstantAnimationDeltaTime: boolean;
  99512. /**
  99513. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  99514. * Please note that it requires to run a ray cast through the scene on every frame
  99515. */
  99516. constantlyUpdateMeshUnderPointer: boolean;
  99517. /**
  99518. * Defines the HTML cursor to use when hovering over interactive elements
  99519. */
  99520. hoverCursor: string;
  99521. /**
  99522. * Defines the HTML default cursor to use (empty by default)
  99523. */
  99524. defaultCursor: string;
  99525. /**
  99526. * This is used to call preventDefault() on pointer down
  99527. * in order to block unwanted artifacts like system double clicks
  99528. */
  99529. preventDefaultOnPointerDown: boolean;
  99530. /**
  99531. * This is used to call preventDefault() on pointer up
  99532. * in order to block unwanted artifacts like system double clicks
  99533. */
  99534. preventDefaultOnPointerUp: boolean;
  99535. /**
  99536. * Gets or sets user defined metadata
  99537. */
  99538. metadata: any;
  99539. /**
  99540. * For internal use only. Please do not use.
  99541. */
  99542. reservedDataStore: any;
  99543. /**
  99544. * Gets the name of the plugin used to load this scene (null by default)
  99545. */
  99546. loadingPluginName: string;
  99547. /**
  99548. * Use this array to add regular expressions used to disable offline support for specific urls
  99549. */
  99550. disableOfflineSupportExceptionRules: RegExp[];
  99551. /**
  99552. * An event triggered when the scene is disposed.
  99553. */
  99554. onDisposeObservable: Observable<Scene>;
  99555. private _onDisposeObserver;
  99556. /** Sets a function to be executed when this scene is disposed. */
  99557. onDispose: () => void;
  99558. /**
  99559. * An event triggered before rendering the scene (right after animations and physics)
  99560. */
  99561. onBeforeRenderObservable: Observable<Scene>;
  99562. private _onBeforeRenderObserver;
  99563. /** Sets a function to be executed before rendering this scene */
  99564. beforeRender: Nullable<() => void>;
  99565. /**
  99566. * An event triggered after rendering the scene
  99567. */
  99568. onAfterRenderObservable: Observable<Scene>;
  99569. /**
  99570. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  99571. */
  99572. onAfterRenderCameraObservable: Observable<Camera>;
  99573. private _onAfterRenderObserver;
  99574. /** Sets a function to be executed after rendering this scene */
  99575. afterRender: Nullable<() => void>;
  99576. /**
  99577. * An event triggered before animating the scene
  99578. */
  99579. onBeforeAnimationsObservable: Observable<Scene>;
  99580. /**
  99581. * An event triggered after animations processing
  99582. */
  99583. onAfterAnimationsObservable: Observable<Scene>;
  99584. /**
  99585. * An event triggered before draw calls are ready to be sent
  99586. */
  99587. onBeforeDrawPhaseObservable: Observable<Scene>;
  99588. /**
  99589. * An event triggered after draw calls have been sent
  99590. */
  99591. onAfterDrawPhaseObservable: Observable<Scene>;
  99592. /**
  99593. * An event triggered when the scene is ready
  99594. */
  99595. onReadyObservable: Observable<Scene>;
  99596. /**
  99597. * An event triggered before rendering a camera
  99598. */
  99599. onBeforeCameraRenderObservable: Observable<Camera>;
  99600. private _onBeforeCameraRenderObserver;
  99601. /** Sets a function to be executed before rendering a camera*/
  99602. beforeCameraRender: () => void;
  99603. /**
  99604. * An event triggered after rendering a camera
  99605. */
  99606. onAfterCameraRenderObservable: Observable<Camera>;
  99607. private _onAfterCameraRenderObserver;
  99608. /** Sets a function to be executed after rendering a camera*/
  99609. afterCameraRender: () => void;
  99610. /**
  99611. * An event triggered when active meshes evaluation is about to start
  99612. */
  99613. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  99614. /**
  99615. * An event triggered when active meshes evaluation is done
  99616. */
  99617. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  99618. /**
  99619. * An event triggered when particles rendering is about to start
  99620. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  99621. */
  99622. onBeforeParticlesRenderingObservable: Observable<Scene>;
  99623. /**
  99624. * An event triggered when particles rendering is done
  99625. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  99626. */
  99627. onAfterParticlesRenderingObservable: Observable<Scene>;
  99628. /**
  99629. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  99630. */
  99631. onDataLoadedObservable: Observable<Scene>;
  99632. /**
  99633. * An event triggered when a camera is created
  99634. */
  99635. onNewCameraAddedObservable: Observable<Camera>;
  99636. /**
  99637. * An event triggered when a camera is removed
  99638. */
  99639. onCameraRemovedObservable: Observable<Camera>;
  99640. /**
  99641. * An event triggered when a light is created
  99642. */
  99643. onNewLightAddedObservable: Observable<Light>;
  99644. /**
  99645. * An event triggered when a light is removed
  99646. */
  99647. onLightRemovedObservable: Observable<Light>;
  99648. /**
  99649. * An event triggered when a geometry is created
  99650. */
  99651. onNewGeometryAddedObservable: Observable<Geometry>;
  99652. /**
  99653. * An event triggered when a geometry is removed
  99654. */
  99655. onGeometryRemovedObservable: Observable<Geometry>;
  99656. /**
  99657. * An event triggered when a transform node is created
  99658. */
  99659. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  99660. /**
  99661. * An event triggered when a transform node is removed
  99662. */
  99663. onTransformNodeRemovedObservable: Observable<TransformNode>;
  99664. /**
  99665. * An event triggered when a mesh is created
  99666. */
  99667. onNewMeshAddedObservable: Observable<AbstractMesh>;
  99668. /**
  99669. * An event triggered when a mesh is removed
  99670. */
  99671. onMeshRemovedObservable: Observable<AbstractMesh>;
  99672. /**
  99673. * An event triggered when a skeleton is created
  99674. */
  99675. onNewSkeletonAddedObservable: Observable<Skeleton>;
  99676. /**
  99677. * An event triggered when a skeleton is removed
  99678. */
  99679. onSkeletonRemovedObservable: Observable<Skeleton>;
  99680. /**
  99681. * An event triggered when a material is created
  99682. */
  99683. onNewMaterialAddedObservable: Observable<Material>;
  99684. /**
  99685. * An event triggered when a material is removed
  99686. */
  99687. onMaterialRemovedObservable: Observable<Material>;
  99688. /**
  99689. * An event triggered when a texture is created
  99690. */
  99691. onNewTextureAddedObservable: Observable<BaseTexture>;
  99692. /**
  99693. * An event triggered when a texture is removed
  99694. */
  99695. onTextureRemovedObservable: Observable<BaseTexture>;
  99696. /**
  99697. * An event triggered when render targets are about to be rendered
  99698. * Can happen multiple times per frame.
  99699. */
  99700. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  99701. /**
  99702. * An event triggered when render targets were rendered.
  99703. * Can happen multiple times per frame.
  99704. */
  99705. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  99706. /**
  99707. * An event triggered before calculating deterministic simulation step
  99708. */
  99709. onBeforeStepObservable: Observable<Scene>;
  99710. /**
  99711. * An event triggered after calculating deterministic simulation step
  99712. */
  99713. onAfterStepObservable: Observable<Scene>;
  99714. /**
  99715. * An event triggered when the activeCamera property is updated
  99716. */
  99717. onActiveCameraChanged: Observable<Scene>;
  99718. /**
  99719. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  99720. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  99721. * 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)
  99722. */
  99723. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  99724. /**
  99725. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  99726. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  99727. * 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)
  99728. */
  99729. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  99730. /**
  99731. * This Observable will when a mesh has been imported into the scene.
  99732. */
  99733. onMeshImportedObservable: Observable<AbstractMesh>;
  99734. /**
  99735. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  99736. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  99737. */
  99738. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  99739. /** @hidden */
  99740. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  99741. /**
  99742. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  99743. */
  99744. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  99745. /**
  99746. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  99747. */
  99748. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  99749. /**
  99750. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  99751. */
  99752. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  99753. /** Callback called when a pointer move is detected */
  99754. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  99755. /** Callback called when a pointer down is detected */
  99756. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  99757. /** Callback called when a pointer up is detected */
  99758. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  99759. /** Callback called when a pointer pick is detected */
  99760. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  99761. /**
  99762. * 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).
  99763. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  99764. */
  99765. onPrePointerObservable: Observable<PointerInfoPre>;
  99766. /**
  99767. * Observable event triggered each time an input event is received from the rendering canvas
  99768. */
  99769. onPointerObservable: Observable<PointerInfo>;
  99770. /**
  99771. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  99772. */
  99773. readonly unTranslatedPointer: Vector2;
  99774. /**
  99775. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  99776. */
  99777. static DragMovementThreshold: number;
  99778. /**
  99779. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  99780. */
  99781. static LongPressDelay: number;
  99782. /**
  99783. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  99784. */
  99785. static DoubleClickDelay: number;
  99786. /** If you need to check double click without raising a single click at first click, enable this flag */
  99787. static ExclusiveDoubleClickMode: boolean;
  99788. /** @hidden */
  99789. _mirroredCameraPosition: Nullable<Vector3>;
  99790. /**
  99791. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  99792. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  99793. */
  99794. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  99795. /**
  99796. * Observable event triggered each time an keyboard event is received from the hosting window
  99797. */
  99798. onKeyboardObservable: Observable<KeyboardInfo>;
  99799. private _useRightHandedSystem;
  99800. /**
  99801. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  99802. */
  99803. useRightHandedSystem: boolean;
  99804. private _timeAccumulator;
  99805. private _currentStepId;
  99806. private _currentInternalStep;
  99807. /**
  99808. * Sets the step Id used by deterministic lock step
  99809. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99810. * @param newStepId defines the step Id
  99811. */
  99812. setStepId(newStepId: number): void;
  99813. /**
  99814. * Gets the step Id used by deterministic lock step
  99815. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99816. * @returns the step Id
  99817. */
  99818. getStepId(): number;
  99819. /**
  99820. * Gets the internal step used by deterministic lock step
  99821. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99822. * @returns the internal step
  99823. */
  99824. getInternalStep(): number;
  99825. private _fogEnabled;
  99826. /**
  99827. * Gets or sets a boolean indicating if fog is enabled on this scene
  99828. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99829. * (Default is true)
  99830. */
  99831. fogEnabled: boolean;
  99832. private _fogMode;
  99833. /**
  99834. * Gets or sets the fog mode to use
  99835. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99836. * | mode | value |
  99837. * | --- | --- |
  99838. * | FOGMODE_NONE | 0 |
  99839. * | FOGMODE_EXP | 1 |
  99840. * | FOGMODE_EXP2 | 2 |
  99841. * | FOGMODE_LINEAR | 3 |
  99842. */
  99843. fogMode: number;
  99844. /**
  99845. * Gets or sets the fog color to use
  99846. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99847. * (Default is Color3(0.2, 0.2, 0.3))
  99848. */
  99849. fogColor: Color3;
  99850. /**
  99851. * Gets or sets the fog density to use
  99852. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99853. * (Default is 0.1)
  99854. */
  99855. fogDensity: number;
  99856. /**
  99857. * Gets or sets the fog start distance to use
  99858. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99859. * (Default is 0)
  99860. */
  99861. fogStart: number;
  99862. /**
  99863. * Gets or sets the fog end distance to use
  99864. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99865. * (Default is 1000)
  99866. */
  99867. fogEnd: number;
  99868. private _shadowsEnabled;
  99869. /**
  99870. * Gets or sets a boolean indicating if shadows are enabled on this scene
  99871. */
  99872. shadowsEnabled: boolean;
  99873. private _lightsEnabled;
  99874. /**
  99875. * Gets or sets a boolean indicating if lights are enabled on this scene
  99876. */
  99877. lightsEnabled: boolean;
  99878. /** All of the active cameras added to this scene. */
  99879. activeCameras: Camera[];
  99880. /** @hidden */
  99881. _activeCamera: Nullable<Camera>;
  99882. /** Gets or sets the current active camera */
  99883. activeCamera: Nullable<Camera>;
  99884. private _defaultMaterial;
  99885. /** The default material used on meshes when no material is affected */
  99886. /** The default material used on meshes when no material is affected */
  99887. defaultMaterial: Material;
  99888. private _texturesEnabled;
  99889. /**
  99890. * Gets or sets a boolean indicating if textures are enabled on this scene
  99891. */
  99892. texturesEnabled: boolean;
  99893. /**
  99894. * Gets or sets a boolean indicating if particles are enabled on this scene
  99895. */
  99896. particlesEnabled: boolean;
  99897. /**
  99898. * Gets or sets a boolean indicating if sprites are enabled on this scene
  99899. */
  99900. spritesEnabled: boolean;
  99901. private _skeletonsEnabled;
  99902. /**
  99903. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  99904. */
  99905. skeletonsEnabled: boolean;
  99906. /**
  99907. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  99908. */
  99909. lensFlaresEnabled: boolean;
  99910. /**
  99911. * Gets or sets a boolean indicating if collisions are enabled on this scene
  99912. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99913. */
  99914. collisionsEnabled: boolean;
  99915. private _collisionCoordinator;
  99916. /** @hidden */
  99917. readonly collisionCoordinator: ICollisionCoordinator;
  99918. /**
  99919. * Defines the gravity applied to this scene (used only for collisions)
  99920. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99921. */
  99922. gravity: Vector3;
  99923. /**
  99924. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  99925. */
  99926. postProcessesEnabled: boolean;
  99927. /**
  99928. * The list of postprocesses added to the scene
  99929. */
  99930. postProcesses: PostProcess[];
  99931. /**
  99932. * Gets the current postprocess manager
  99933. */
  99934. postProcessManager: PostProcessManager;
  99935. /**
  99936. * Gets or sets a boolean indicating if render targets are enabled on this scene
  99937. */
  99938. renderTargetsEnabled: boolean;
  99939. /**
  99940. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  99941. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  99942. */
  99943. dumpNextRenderTargets: boolean;
  99944. /**
  99945. * The list of user defined render targets added to the scene
  99946. */
  99947. customRenderTargets: RenderTargetTexture[];
  99948. /**
  99949. * Defines if texture loading must be delayed
  99950. * If true, textures will only be loaded when they need to be rendered
  99951. */
  99952. useDelayedTextureLoading: boolean;
  99953. /**
  99954. * Gets the list of meshes imported to the scene through SceneLoader
  99955. */
  99956. importedMeshesFiles: String[];
  99957. /**
  99958. * Gets or sets a boolean indicating if probes are enabled on this scene
  99959. */
  99960. probesEnabled: boolean;
  99961. /**
  99962. * Gets or sets the current offline provider to use to store scene data
  99963. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  99964. */
  99965. offlineProvider: IOfflineProvider;
  99966. /**
  99967. * Gets or sets the action manager associated with the scene
  99968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99969. */
  99970. actionManager: AbstractActionManager;
  99971. private _meshesForIntersections;
  99972. /**
  99973. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  99974. */
  99975. proceduralTexturesEnabled: boolean;
  99976. private _engine;
  99977. private _totalVertices;
  99978. /** @hidden */
  99979. _activeIndices: PerfCounter;
  99980. /** @hidden */
  99981. _activeParticles: PerfCounter;
  99982. /** @hidden */
  99983. _activeBones: PerfCounter;
  99984. private _animationRatio;
  99985. /** @hidden */
  99986. _animationTimeLast: number;
  99987. /** @hidden */
  99988. _animationTime: number;
  99989. /**
  99990. * Gets or sets a general scale for animation speed
  99991. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  99992. */
  99993. animationTimeScale: number;
  99994. /** @hidden */
  99995. _cachedMaterial: Nullable<Material>;
  99996. /** @hidden */
  99997. _cachedEffect: Nullable<Effect>;
  99998. /** @hidden */
  99999. _cachedVisibility: Nullable<number>;
  100000. private _renderId;
  100001. private _frameId;
  100002. private _executeWhenReadyTimeoutId;
  100003. private _intermediateRendering;
  100004. private _viewUpdateFlag;
  100005. private _projectionUpdateFlag;
  100006. /** @hidden */
  100007. _toBeDisposed: Nullable<IDisposable>[];
  100008. private _activeRequests;
  100009. /** @hidden */
  100010. _pendingData: any[];
  100011. private _isDisposed;
  100012. /**
  100013. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  100014. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  100015. */
  100016. dispatchAllSubMeshesOfActiveMeshes: boolean;
  100017. private _activeMeshes;
  100018. private _processedMaterials;
  100019. private _renderTargets;
  100020. /** @hidden */
  100021. _activeParticleSystems: SmartArray<IParticleSystem>;
  100022. private _activeSkeletons;
  100023. private _softwareSkinnedMeshes;
  100024. private _renderingManager;
  100025. /** @hidden */
  100026. _activeAnimatables: Animatable[];
  100027. private _transformMatrix;
  100028. private _sceneUbo;
  100029. /** @hidden */
  100030. _viewMatrix: Matrix;
  100031. private _projectionMatrix;
  100032. /** @hidden */
  100033. _forcedViewPosition: Nullable<Vector3>;
  100034. /** @hidden */
  100035. _frustumPlanes: Plane[];
  100036. /**
  100037. * Gets the list of frustum planes (built from the active camera)
  100038. */
  100039. readonly frustumPlanes: Plane[];
  100040. /**
  100041. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  100042. * This is useful if there are more lights that the maximum simulteanous authorized
  100043. */
  100044. requireLightSorting: boolean;
  100045. /** @hidden */
  100046. readonly useMaterialMeshMap: boolean;
  100047. /** @hidden */
  100048. readonly useClonedMeshhMap: boolean;
  100049. private _externalData;
  100050. private _uid;
  100051. /**
  100052. * @hidden
  100053. * Backing store of defined scene components.
  100054. */
  100055. _components: ISceneComponent[];
  100056. /**
  100057. * @hidden
  100058. * Backing store of defined scene components.
  100059. */
  100060. _serializableComponents: ISceneSerializableComponent[];
  100061. /**
  100062. * List of components to register on the next registration step.
  100063. */
  100064. private _transientComponents;
  100065. /**
  100066. * Registers the transient components if needed.
  100067. */
  100068. private _registerTransientComponents;
  100069. /**
  100070. * @hidden
  100071. * Add a component to the scene.
  100072. * Note that the ccomponent could be registered on th next frame if this is called after
  100073. * the register component stage.
  100074. * @param component Defines the component to add to the scene
  100075. */
  100076. _addComponent(component: ISceneComponent): void;
  100077. /**
  100078. * @hidden
  100079. * Gets a component from the scene.
  100080. * @param name defines the name of the component to retrieve
  100081. * @returns the component or null if not present
  100082. */
  100083. _getComponent(name: string): Nullable<ISceneComponent>;
  100084. /**
  100085. * @hidden
  100086. * Defines the actions happening before camera updates.
  100087. */
  100088. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  100089. /**
  100090. * @hidden
  100091. * Defines the actions happening before clear the canvas.
  100092. */
  100093. _beforeClearStage: Stage<SimpleStageAction>;
  100094. /**
  100095. * @hidden
  100096. * Defines the actions when collecting render targets for the frame.
  100097. */
  100098. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100099. /**
  100100. * @hidden
  100101. * Defines the actions happening for one camera in the frame.
  100102. */
  100103. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100104. /**
  100105. * @hidden
  100106. * Defines the actions happening during the per mesh ready checks.
  100107. */
  100108. _isReadyForMeshStage: Stage<MeshStageAction>;
  100109. /**
  100110. * @hidden
  100111. * Defines the actions happening before evaluate active mesh checks.
  100112. */
  100113. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  100114. /**
  100115. * @hidden
  100116. * Defines the actions happening during the evaluate sub mesh checks.
  100117. */
  100118. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  100119. /**
  100120. * @hidden
  100121. * Defines the actions happening during the active mesh stage.
  100122. */
  100123. _activeMeshStage: Stage<ActiveMeshStageAction>;
  100124. /**
  100125. * @hidden
  100126. * Defines the actions happening during the per camera render target step.
  100127. */
  100128. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  100129. /**
  100130. * @hidden
  100131. * Defines the actions happening just before the active camera is drawing.
  100132. */
  100133. _beforeCameraDrawStage: Stage<CameraStageAction>;
  100134. /**
  100135. * @hidden
  100136. * Defines the actions happening just before a render target is drawing.
  100137. */
  100138. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100139. /**
  100140. * @hidden
  100141. * Defines the actions happening just before a rendering group is drawing.
  100142. */
  100143. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100144. /**
  100145. * @hidden
  100146. * Defines the actions happening just before a mesh is drawing.
  100147. */
  100148. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100149. /**
  100150. * @hidden
  100151. * Defines the actions happening just after a mesh has been drawn.
  100152. */
  100153. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100154. /**
  100155. * @hidden
  100156. * Defines the actions happening just after a rendering group has been drawn.
  100157. */
  100158. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100159. /**
  100160. * @hidden
  100161. * Defines the actions happening just after the active camera has been drawn.
  100162. */
  100163. _afterCameraDrawStage: Stage<CameraStageAction>;
  100164. /**
  100165. * @hidden
  100166. * Defines the actions happening just after a render target has been drawn.
  100167. */
  100168. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100169. /**
  100170. * @hidden
  100171. * Defines the actions happening just after rendering all cameras and computing intersections.
  100172. */
  100173. _afterRenderStage: Stage<SimpleStageAction>;
  100174. /**
  100175. * @hidden
  100176. * Defines the actions happening when a pointer move event happens.
  100177. */
  100178. _pointerMoveStage: Stage<PointerMoveStageAction>;
  100179. /**
  100180. * @hidden
  100181. * Defines the actions happening when a pointer down event happens.
  100182. */
  100183. _pointerDownStage: Stage<PointerUpDownStageAction>;
  100184. /**
  100185. * @hidden
  100186. * Defines the actions happening when a pointer up event happens.
  100187. */
  100188. _pointerUpStage: Stage<PointerUpDownStageAction>;
  100189. /**
  100190. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  100191. */
  100192. private geometriesByUniqueId;
  100193. /**
  100194. * Creates a new Scene
  100195. * @param engine defines the engine to use to render this scene
  100196. * @param options defines the scene options
  100197. */
  100198. constructor(engine: Engine, options?: SceneOptions);
  100199. /**
  100200. * Gets a string idenfifying the name of the class
  100201. * @returns "Scene" string
  100202. */
  100203. getClassName(): string;
  100204. private _defaultMeshCandidates;
  100205. /**
  100206. * @hidden
  100207. */
  100208. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100209. private _defaultSubMeshCandidates;
  100210. /**
  100211. * @hidden
  100212. */
  100213. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100214. /**
  100215. * Sets the default candidate providers for the scene.
  100216. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  100217. * and getCollidingSubMeshCandidates to their default function
  100218. */
  100219. setDefaultCandidateProviders(): void;
  100220. /**
  100221. * Gets the mesh that is currently under the pointer
  100222. */
  100223. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100224. /**
  100225. * Gets or sets the current on-screen X position of the pointer
  100226. */
  100227. pointerX: number;
  100228. /**
  100229. * Gets or sets the current on-screen Y position of the pointer
  100230. */
  100231. pointerY: number;
  100232. /**
  100233. * Gets the cached material (ie. the latest rendered one)
  100234. * @returns the cached material
  100235. */
  100236. getCachedMaterial(): Nullable<Material>;
  100237. /**
  100238. * Gets the cached effect (ie. the latest rendered one)
  100239. * @returns the cached effect
  100240. */
  100241. getCachedEffect(): Nullable<Effect>;
  100242. /**
  100243. * Gets the cached visibility state (ie. the latest rendered one)
  100244. * @returns the cached visibility state
  100245. */
  100246. getCachedVisibility(): Nullable<number>;
  100247. /**
  100248. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  100249. * @param material defines the current material
  100250. * @param effect defines the current effect
  100251. * @param visibility defines the current visibility state
  100252. * @returns true if one parameter is not cached
  100253. */
  100254. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  100255. /**
  100256. * Gets the engine associated with the scene
  100257. * @returns an Engine
  100258. */
  100259. getEngine(): Engine;
  100260. /**
  100261. * Gets the total number of vertices rendered per frame
  100262. * @returns the total number of vertices rendered per frame
  100263. */
  100264. getTotalVertices(): number;
  100265. /**
  100266. * Gets the performance counter for total vertices
  100267. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100268. */
  100269. readonly totalVerticesPerfCounter: PerfCounter;
  100270. /**
  100271. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  100272. * @returns the total number of active indices rendered per frame
  100273. */
  100274. getActiveIndices(): number;
  100275. /**
  100276. * Gets the performance counter for active indices
  100277. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100278. */
  100279. readonly totalActiveIndicesPerfCounter: PerfCounter;
  100280. /**
  100281. * Gets the total number of active particles rendered per frame
  100282. * @returns the total number of active particles rendered per frame
  100283. */
  100284. getActiveParticles(): number;
  100285. /**
  100286. * Gets the performance counter for active particles
  100287. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100288. */
  100289. readonly activeParticlesPerfCounter: PerfCounter;
  100290. /**
  100291. * Gets the total number of active bones rendered per frame
  100292. * @returns the total number of active bones rendered per frame
  100293. */
  100294. getActiveBones(): number;
  100295. /**
  100296. * Gets the performance counter for active bones
  100297. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100298. */
  100299. readonly activeBonesPerfCounter: PerfCounter;
  100300. /**
  100301. * Gets the array of active meshes
  100302. * @returns an array of AbstractMesh
  100303. */
  100304. getActiveMeshes(): SmartArray<AbstractMesh>;
  100305. /**
  100306. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  100307. * @returns a number
  100308. */
  100309. getAnimationRatio(): number;
  100310. /**
  100311. * Gets an unique Id for the current render phase
  100312. * @returns a number
  100313. */
  100314. getRenderId(): number;
  100315. /**
  100316. * Gets an unique Id for the current frame
  100317. * @returns a number
  100318. */
  100319. getFrameId(): number;
  100320. /** Call this function if you want to manually increment the render Id*/
  100321. incrementRenderId(): void;
  100322. private _createUbo;
  100323. /**
  100324. * Use this method to simulate a pointer move on a mesh
  100325. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100326. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100327. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100328. * @returns the current scene
  100329. */
  100330. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100331. /**
  100332. * Use this method to simulate a pointer down on a mesh
  100333. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100334. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100335. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100336. * @returns the current scene
  100337. */
  100338. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100339. /**
  100340. * Use this method to simulate a pointer up on a mesh
  100341. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100342. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100343. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100344. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  100345. * @returns the current scene
  100346. */
  100347. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  100348. /**
  100349. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  100350. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  100351. * @returns true if the pointer was captured
  100352. */
  100353. isPointerCaptured(pointerId?: number): boolean;
  100354. /**
  100355. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  100356. * @param attachUp defines if you want to attach events to pointerup
  100357. * @param attachDown defines if you want to attach events to pointerdown
  100358. * @param attachMove defines if you want to attach events to pointermove
  100359. */
  100360. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  100361. /** Detaches all event handlers*/
  100362. detachControl(): void;
  100363. /**
  100364. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  100365. * Delay loaded resources are not taking in account
  100366. * @return true if all required resources are ready
  100367. */
  100368. isReady(): boolean;
  100369. /** Resets all cached information relative to material (including effect and visibility) */
  100370. resetCachedMaterial(): void;
  100371. /**
  100372. * Registers a function to be called before every frame render
  100373. * @param func defines the function to register
  100374. */
  100375. registerBeforeRender(func: () => void): void;
  100376. /**
  100377. * Unregisters a function called before every frame render
  100378. * @param func defines the function to unregister
  100379. */
  100380. unregisterBeforeRender(func: () => void): void;
  100381. /**
  100382. * Registers a function to be called after every frame render
  100383. * @param func defines the function to register
  100384. */
  100385. registerAfterRender(func: () => void): void;
  100386. /**
  100387. * Unregisters a function called after every frame render
  100388. * @param func defines the function to unregister
  100389. */
  100390. unregisterAfterRender(func: () => void): void;
  100391. private _executeOnceBeforeRender;
  100392. /**
  100393. * The provided function will run before render once and will be disposed afterwards.
  100394. * A timeout delay can be provided so that the function will be executed in N ms.
  100395. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  100396. * @param func The function to be executed.
  100397. * @param timeout optional delay in ms
  100398. */
  100399. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  100400. /** @hidden */
  100401. _addPendingData(data: any): void;
  100402. /** @hidden */
  100403. _removePendingData(data: any): void;
  100404. /**
  100405. * Returns the number of items waiting to be loaded
  100406. * @returns the number of items waiting to be loaded
  100407. */
  100408. getWaitingItemsCount(): number;
  100409. /**
  100410. * Returns a boolean indicating if the scene is still loading data
  100411. */
  100412. readonly isLoading: boolean;
  100413. /**
  100414. * Registers a function to be executed when the scene is ready
  100415. * @param {Function} func - the function to be executed
  100416. */
  100417. executeWhenReady(func: () => void): void;
  100418. /**
  100419. * Returns a promise that resolves when the scene is ready
  100420. * @returns A promise that resolves when the scene is ready
  100421. */
  100422. whenReadyAsync(): Promise<void>;
  100423. /** @hidden */
  100424. _checkIsReady(): void;
  100425. /**
  100426. * Gets all animatable attached to the scene
  100427. */
  100428. readonly animatables: Animatable[];
  100429. /**
  100430. * Resets the last animation time frame.
  100431. * Useful to override when animations start running when loading a scene for the first time.
  100432. */
  100433. resetLastAnimationTimeFrame(): void;
  100434. /**
  100435. * Gets the current view matrix
  100436. * @returns a Matrix
  100437. */
  100438. getViewMatrix(): Matrix;
  100439. /**
  100440. * Gets the current projection matrix
  100441. * @returns a Matrix
  100442. */
  100443. getProjectionMatrix(): Matrix;
  100444. /**
  100445. * Gets the current transform matrix
  100446. * @returns a Matrix made of View * Projection
  100447. */
  100448. getTransformMatrix(): Matrix;
  100449. /**
  100450. * Sets the current transform matrix
  100451. * @param viewL defines the View matrix to use
  100452. * @param projectionL defines the Projection matrix to use
  100453. * @param viewR defines the right View matrix to use (if provided)
  100454. * @param projectionR defines the right Projection matrix to use (if provided)
  100455. */
  100456. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  100457. /**
  100458. * Gets the uniform buffer used to store scene data
  100459. * @returns a UniformBuffer
  100460. */
  100461. getSceneUniformBuffer(): UniformBuffer;
  100462. /**
  100463. * Gets an unique (relatively to the current scene) Id
  100464. * @returns an unique number for the scene
  100465. */
  100466. getUniqueId(): number;
  100467. /**
  100468. * Add a mesh to the list of scene's meshes
  100469. * @param newMesh defines the mesh to add
  100470. * @param recursive if all child meshes should also be added to the scene
  100471. */
  100472. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  100473. /**
  100474. * Remove a mesh for the list of scene's meshes
  100475. * @param toRemove defines the mesh to remove
  100476. * @param recursive if all child meshes should also be removed from the scene
  100477. * @returns the index where the mesh was in the mesh list
  100478. */
  100479. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  100480. /**
  100481. * Add a transform node to the list of scene's transform nodes
  100482. * @param newTransformNode defines the transform node to add
  100483. */
  100484. addTransformNode(newTransformNode: TransformNode): void;
  100485. /**
  100486. * Remove a transform node for the list of scene's transform nodes
  100487. * @param toRemove defines the transform node to remove
  100488. * @returns the index where the transform node was in the transform node list
  100489. */
  100490. removeTransformNode(toRemove: TransformNode): number;
  100491. /**
  100492. * Remove a skeleton for the list of scene's skeletons
  100493. * @param toRemove defines the skeleton to remove
  100494. * @returns the index where the skeleton was in the skeleton list
  100495. */
  100496. removeSkeleton(toRemove: Skeleton): number;
  100497. /**
  100498. * Remove a morph target for the list of scene's morph targets
  100499. * @param toRemove defines the morph target to remove
  100500. * @returns the index where the morph target was in the morph target list
  100501. */
  100502. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  100503. /**
  100504. * Remove a light for the list of scene's lights
  100505. * @param toRemove defines the light to remove
  100506. * @returns the index where the light was in the light list
  100507. */
  100508. removeLight(toRemove: Light): number;
  100509. /**
  100510. * Remove a camera for the list of scene's cameras
  100511. * @param toRemove defines the camera to remove
  100512. * @returns the index where the camera was in the camera list
  100513. */
  100514. removeCamera(toRemove: Camera): number;
  100515. /**
  100516. * Remove a particle system for the list of scene's particle systems
  100517. * @param toRemove defines the particle system to remove
  100518. * @returns the index where the particle system was in the particle system list
  100519. */
  100520. removeParticleSystem(toRemove: IParticleSystem): number;
  100521. /**
  100522. * Remove a animation for the list of scene's animations
  100523. * @param toRemove defines the animation to remove
  100524. * @returns the index where the animation was in the animation list
  100525. */
  100526. removeAnimation(toRemove: Animation): number;
  100527. /**
  100528. * Will stop the animation of the given target
  100529. * @param target - the target
  100530. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  100531. * @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)
  100532. */
  100533. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  100534. /**
  100535. * Removes the given animation group from this scene.
  100536. * @param toRemove The animation group to remove
  100537. * @returns The index of the removed animation group
  100538. */
  100539. removeAnimationGroup(toRemove: AnimationGroup): number;
  100540. /**
  100541. * Removes the given multi-material from this scene.
  100542. * @param toRemove The multi-material to remove
  100543. * @returns The index of the removed multi-material
  100544. */
  100545. removeMultiMaterial(toRemove: MultiMaterial): number;
  100546. /**
  100547. * Removes the given material from this scene.
  100548. * @param toRemove The material to remove
  100549. * @returns The index of the removed material
  100550. */
  100551. removeMaterial(toRemove: Material): number;
  100552. /**
  100553. * Removes the given action manager from this scene.
  100554. * @param toRemove The action manager to remove
  100555. * @returns The index of the removed action manager
  100556. */
  100557. removeActionManager(toRemove: AbstractActionManager): number;
  100558. /**
  100559. * Removes the given texture from this scene.
  100560. * @param toRemove The texture to remove
  100561. * @returns The index of the removed texture
  100562. */
  100563. removeTexture(toRemove: BaseTexture): number;
  100564. /**
  100565. * Adds the given light to this scene
  100566. * @param newLight The light to add
  100567. */
  100568. addLight(newLight: Light): void;
  100569. /**
  100570. * Sorts the list list based on light priorities
  100571. */
  100572. sortLightsByPriority(): void;
  100573. /**
  100574. * Adds the given camera to this scene
  100575. * @param newCamera The camera to add
  100576. */
  100577. addCamera(newCamera: Camera): void;
  100578. /**
  100579. * Adds the given skeleton to this scene
  100580. * @param newSkeleton The skeleton to add
  100581. */
  100582. addSkeleton(newSkeleton: Skeleton): void;
  100583. /**
  100584. * Adds the given particle system to this scene
  100585. * @param newParticleSystem The particle system to add
  100586. */
  100587. addParticleSystem(newParticleSystem: IParticleSystem): void;
  100588. /**
  100589. * Adds the given animation to this scene
  100590. * @param newAnimation The animation to add
  100591. */
  100592. addAnimation(newAnimation: Animation): void;
  100593. /**
  100594. * Adds the given animation group to this scene.
  100595. * @param newAnimationGroup The animation group to add
  100596. */
  100597. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  100598. /**
  100599. * Adds the given multi-material to this scene
  100600. * @param newMultiMaterial The multi-material to add
  100601. */
  100602. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  100603. /**
  100604. * Adds the given material to this scene
  100605. * @param newMaterial The material to add
  100606. */
  100607. addMaterial(newMaterial: Material): void;
  100608. /**
  100609. * Adds the given morph target to this scene
  100610. * @param newMorphTargetManager The morph target to add
  100611. */
  100612. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  100613. /**
  100614. * Adds the given geometry to this scene
  100615. * @param newGeometry The geometry to add
  100616. */
  100617. addGeometry(newGeometry: Geometry): void;
  100618. /**
  100619. * Adds the given action manager to this scene
  100620. * @param newActionManager The action manager to add
  100621. */
  100622. addActionManager(newActionManager: AbstractActionManager): void;
  100623. /**
  100624. * Adds the given texture to this scene.
  100625. * @param newTexture The texture to add
  100626. */
  100627. addTexture(newTexture: BaseTexture): void;
  100628. /**
  100629. * Switch active camera
  100630. * @param newCamera defines the new active camera
  100631. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  100632. */
  100633. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  100634. /**
  100635. * sets the active camera of the scene using its ID
  100636. * @param id defines the camera's ID
  100637. * @return the new active camera or null if none found.
  100638. */
  100639. setActiveCameraByID(id: string): Nullable<Camera>;
  100640. /**
  100641. * sets the active camera of the scene using its name
  100642. * @param name defines the camera's name
  100643. * @returns the new active camera or null if none found.
  100644. */
  100645. setActiveCameraByName(name: string): Nullable<Camera>;
  100646. /**
  100647. * get an animation group using its name
  100648. * @param name defines the material's name
  100649. * @return the animation group or null if none found.
  100650. */
  100651. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  100652. /**
  100653. * Get a material using its unique id
  100654. * @param uniqueId defines the material's unique id
  100655. * @return the material or null if none found.
  100656. */
  100657. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  100658. /**
  100659. * get a material using its id
  100660. * @param id defines the material's ID
  100661. * @return the material or null if none found.
  100662. */
  100663. getMaterialByID(id: string): Nullable<Material>;
  100664. /**
  100665. * Gets a the last added material using a given id
  100666. * @param id defines the material's ID
  100667. * @return the last material with the given id or null if none found.
  100668. */
  100669. getLastMaterialByID(id: string): Nullable<Material>;
  100670. /**
  100671. * Gets a material using its name
  100672. * @param name defines the material's name
  100673. * @return the material or null if none found.
  100674. */
  100675. getMaterialByName(name: string): Nullable<Material>;
  100676. /**
  100677. * Get a texture using its unique id
  100678. * @param uniqueId defines the texture's unique id
  100679. * @return the texture or null if none found.
  100680. */
  100681. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  100682. /**
  100683. * Gets a camera using its id
  100684. * @param id defines the id to look for
  100685. * @returns the camera or null if not found
  100686. */
  100687. getCameraByID(id: string): Nullable<Camera>;
  100688. /**
  100689. * Gets a camera using its unique id
  100690. * @param uniqueId defines the unique id to look for
  100691. * @returns the camera or null if not found
  100692. */
  100693. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  100694. /**
  100695. * Gets a camera using its name
  100696. * @param name defines the camera's name
  100697. * @return the camera or null if none found.
  100698. */
  100699. getCameraByName(name: string): Nullable<Camera>;
  100700. /**
  100701. * Gets a bone using its id
  100702. * @param id defines the bone's id
  100703. * @return the bone or null if not found
  100704. */
  100705. getBoneByID(id: string): Nullable<Bone>;
  100706. /**
  100707. * Gets a bone using its id
  100708. * @param name defines the bone's name
  100709. * @return the bone or null if not found
  100710. */
  100711. getBoneByName(name: string): Nullable<Bone>;
  100712. /**
  100713. * Gets a light node using its name
  100714. * @param name defines the the light's name
  100715. * @return the light or null if none found.
  100716. */
  100717. getLightByName(name: string): Nullable<Light>;
  100718. /**
  100719. * Gets a light node using its id
  100720. * @param id defines the light's id
  100721. * @return the light or null if none found.
  100722. */
  100723. getLightByID(id: string): Nullable<Light>;
  100724. /**
  100725. * Gets a light node using its scene-generated unique ID
  100726. * @param uniqueId defines the light's unique id
  100727. * @return the light or null if none found.
  100728. */
  100729. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  100730. /**
  100731. * Gets a particle system by id
  100732. * @param id defines the particle system id
  100733. * @return the corresponding system or null if none found
  100734. */
  100735. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  100736. /**
  100737. * Gets a geometry using its ID
  100738. * @param id defines the geometry's id
  100739. * @return the geometry or null if none found.
  100740. */
  100741. getGeometryByID(id: string): Nullable<Geometry>;
  100742. private _getGeometryByUniqueID;
  100743. /**
  100744. * Add a new geometry to this scene
  100745. * @param geometry defines the geometry to be added to the scene.
  100746. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  100747. * @return a boolean defining if the geometry was added or not
  100748. */
  100749. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  100750. /**
  100751. * Removes an existing geometry
  100752. * @param geometry defines the geometry to be removed from the scene
  100753. * @return a boolean defining if the geometry was removed or not
  100754. */
  100755. removeGeometry(geometry: Geometry): boolean;
  100756. /**
  100757. * Gets the list of geometries attached to the scene
  100758. * @returns an array of Geometry
  100759. */
  100760. getGeometries(): Geometry[];
  100761. /**
  100762. * Gets the first added mesh found of a given ID
  100763. * @param id defines the id to search for
  100764. * @return the mesh found or null if not found at all
  100765. */
  100766. getMeshByID(id: string): Nullable<AbstractMesh>;
  100767. /**
  100768. * Gets a list of meshes using their id
  100769. * @param id defines the id to search for
  100770. * @returns a list of meshes
  100771. */
  100772. getMeshesByID(id: string): Array<AbstractMesh>;
  100773. /**
  100774. * Gets the first added transform node found of a given ID
  100775. * @param id defines the id to search for
  100776. * @return the found transform node or null if not found at all.
  100777. */
  100778. getTransformNodeByID(id: string): Nullable<TransformNode>;
  100779. /**
  100780. * Gets a transform node with its auto-generated unique id
  100781. * @param uniqueId efines the unique id to search for
  100782. * @return the found transform node or null if not found at all.
  100783. */
  100784. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  100785. /**
  100786. * Gets a list of transform nodes using their id
  100787. * @param id defines the id to search for
  100788. * @returns a list of transform nodes
  100789. */
  100790. getTransformNodesByID(id: string): Array<TransformNode>;
  100791. /**
  100792. * Gets a mesh with its auto-generated unique id
  100793. * @param uniqueId defines the unique id to search for
  100794. * @return the found mesh or null if not found at all.
  100795. */
  100796. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  100797. /**
  100798. * Gets a the last added mesh using a given id
  100799. * @param id defines the id to search for
  100800. * @return the found mesh or null if not found at all.
  100801. */
  100802. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  100803. /**
  100804. * Gets a the last added node (Mesh, Camera, Light) using a given id
  100805. * @param id defines the id to search for
  100806. * @return the found node or null if not found at all
  100807. */
  100808. getLastEntryByID(id: string): Nullable<Node>;
  100809. /**
  100810. * Gets a node (Mesh, Camera, Light) using a given id
  100811. * @param id defines the id to search for
  100812. * @return the found node or null if not found at all
  100813. */
  100814. getNodeByID(id: string): Nullable<Node>;
  100815. /**
  100816. * Gets a node (Mesh, Camera, Light) using a given name
  100817. * @param name defines the name to search for
  100818. * @return the found node or null if not found at all.
  100819. */
  100820. getNodeByName(name: string): Nullable<Node>;
  100821. /**
  100822. * Gets a mesh using a given name
  100823. * @param name defines the name to search for
  100824. * @return the found mesh or null if not found at all.
  100825. */
  100826. getMeshByName(name: string): Nullable<AbstractMesh>;
  100827. /**
  100828. * Gets a transform node using a given name
  100829. * @param name defines the name to search for
  100830. * @return the found transform node or null if not found at all.
  100831. */
  100832. getTransformNodeByName(name: string): Nullable<TransformNode>;
  100833. /**
  100834. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  100835. * @param id defines the id to search for
  100836. * @return the found skeleton or null if not found at all.
  100837. */
  100838. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  100839. /**
  100840. * Gets a skeleton using a given auto generated unique id
  100841. * @param uniqueId defines the unique id to search for
  100842. * @return the found skeleton or null if not found at all.
  100843. */
  100844. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  100845. /**
  100846. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  100847. * @param id defines the id to search for
  100848. * @return the found skeleton or null if not found at all.
  100849. */
  100850. getSkeletonById(id: string): Nullable<Skeleton>;
  100851. /**
  100852. * Gets a skeleton using a given name
  100853. * @param name defines the name to search for
  100854. * @return the found skeleton or null if not found at all.
  100855. */
  100856. getSkeletonByName(name: string): Nullable<Skeleton>;
  100857. /**
  100858. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  100859. * @param id defines the id to search for
  100860. * @return the found morph target manager or null if not found at all.
  100861. */
  100862. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  100863. /**
  100864. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  100865. * @param id defines the id to search for
  100866. * @return the found morph target or null if not found at all.
  100867. */
  100868. getMorphTargetById(id: string): Nullable<MorphTarget>;
  100869. /**
  100870. * Gets a boolean indicating if the given mesh is active
  100871. * @param mesh defines the mesh to look for
  100872. * @returns true if the mesh is in the active list
  100873. */
  100874. isActiveMesh(mesh: AbstractMesh): boolean;
  100875. /**
  100876. * Return a unique id as a string which can serve as an identifier for the scene
  100877. */
  100878. readonly uid: string;
  100879. /**
  100880. * Add an externaly attached data from its key.
  100881. * This method call will fail and return false, if such key already exists.
  100882. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  100883. * @param key the unique key that identifies the data
  100884. * @param data the data object to associate to the key for this Engine instance
  100885. * @return true if no such key were already present and the data was added successfully, false otherwise
  100886. */
  100887. addExternalData<T>(key: string, data: T): boolean;
  100888. /**
  100889. * Get an externaly attached data from its key
  100890. * @param key the unique key that identifies the data
  100891. * @return the associated data, if present (can be null), or undefined if not present
  100892. */
  100893. getExternalData<T>(key: string): Nullable<T>;
  100894. /**
  100895. * Get an externaly attached data from its key, create it using a factory if it's not already present
  100896. * @param key the unique key that identifies the data
  100897. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  100898. * @return the associated data, can be null if the factory returned null.
  100899. */
  100900. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  100901. /**
  100902. * Remove an externaly attached data from the Engine instance
  100903. * @param key the unique key that identifies the data
  100904. * @return true if the data was successfully removed, false if it doesn't exist
  100905. */
  100906. removeExternalData(key: string): boolean;
  100907. private _evaluateSubMesh;
  100908. /**
  100909. * Clear the processed materials smart array preventing retention point in material dispose.
  100910. */
  100911. freeProcessedMaterials(): void;
  100912. private _preventFreeActiveMeshesAndRenderingGroups;
  100913. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  100914. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  100915. * when disposing several meshes in a row or a hierarchy of meshes.
  100916. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  100917. */
  100918. blockfreeActiveMeshesAndRenderingGroups: boolean;
  100919. /**
  100920. * Clear the active meshes smart array preventing retention point in mesh dispose.
  100921. */
  100922. freeActiveMeshes(): void;
  100923. /**
  100924. * Clear the info related to rendering groups preventing retention points during dispose.
  100925. */
  100926. freeRenderingGroups(): void;
  100927. /** @hidden */
  100928. _isInIntermediateRendering(): boolean;
  100929. /**
  100930. * Lambda returning the list of potentially active meshes.
  100931. */
  100932. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  100933. /**
  100934. * Lambda returning the list of potentially active sub meshes.
  100935. */
  100936. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  100937. /**
  100938. * Lambda returning the list of potentially intersecting sub meshes.
  100939. */
  100940. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  100941. /**
  100942. * Lambda returning the list of potentially colliding sub meshes.
  100943. */
  100944. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  100945. private _activeMeshesFrozen;
  100946. /**
  100947. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  100948. * @returns the current scene
  100949. */
  100950. freezeActiveMeshes(): Scene;
  100951. /**
  100952. * Use this function to restart evaluating active meshes on every frame
  100953. * @returns the current scene
  100954. */
  100955. unfreezeActiveMeshes(): Scene;
  100956. private _evaluateActiveMeshes;
  100957. private _activeMesh;
  100958. /**
  100959. * Update the transform matrix to update from the current active camera
  100960. * @param force defines a boolean used to force the update even if cache is up to date
  100961. */
  100962. updateTransformMatrix(force?: boolean): void;
  100963. private _bindFrameBuffer;
  100964. /** @hidden */
  100965. _allowPostProcessClearColor: boolean;
  100966. /** @hidden */
  100967. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  100968. private _processSubCameras;
  100969. private _checkIntersections;
  100970. /** @hidden */
  100971. _advancePhysicsEngineStep(step: number): void;
  100972. /**
  100973. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  100974. */
  100975. getDeterministicFrameTime: () => number;
  100976. /** @hidden */
  100977. _animate(): void;
  100978. /** Execute all animations (for a frame) */
  100979. animate(): void;
  100980. /**
  100981. * Render the scene
  100982. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  100983. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  100984. */
  100985. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  100986. /**
  100987. * Freeze all materials
  100988. * A frozen material will not be updatable but should be faster to render
  100989. */
  100990. freezeMaterials(): void;
  100991. /**
  100992. * Unfreeze all materials
  100993. * A frozen material will not be updatable but should be faster to render
  100994. */
  100995. unfreezeMaterials(): void;
  100996. /**
  100997. * Releases all held ressources
  100998. */
  100999. dispose(): void;
  101000. /**
  101001. * Gets if the scene is already disposed
  101002. */
  101003. readonly isDisposed: boolean;
  101004. /**
  101005. * Call this function to reduce memory footprint of the scene.
  101006. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  101007. */
  101008. clearCachedVertexData(): void;
  101009. /**
  101010. * This function will remove the local cached buffer data from texture.
  101011. * It will save memory but will prevent the texture from being rebuilt
  101012. */
  101013. cleanCachedTextureBuffer(): void;
  101014. /**
  101015. * Get the world extend vectors with an optional filter
  101016. *
  101017. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  101018. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  101019. */
  101020. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  101021. min: Vector3;
  101022. max: Vector3;
  101023. };
  101024. /**
  101025. * Creates a ray that can be used to pick in the scene
  101026. * @param x defines the x coordinate of the origin (on-screen)
  101027. * @param y defines the y coordinate of the origin (on-screen)
  101028. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101029. * @param camera defines the camera to use for the picking
  101030. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101031. * @returns a Ray
  101032. */
  101033. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  101034. /**
  101035. * Creates a ray that can be used to pick in the scene
  101036. * @param x defines the x coordinate of the origin (on-screen)
  101037. * @param y defines the y coordinate of the origin (on-screen)
  101038. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101039. * @param result defines the ray where to store the picking ray
  101040. * @param camera defines the camera to use for the picking
  101041. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101042. * @returns the current scene
  101043. */
  101044. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  101045. /**
  101046. * Creates a ray that can be used to pick in the scene
  101047. * @param x defines the x coordinate of the origin (on-screen)
  101048. * @param y defines the y coordinate of the origin (on-screen)
  101049. * @param camera defines the camera to use for the picking
  101050. * @returns a Ray
  101051. */
  101052. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  101053. /**
  101054. * Creates a ray that can be used to pick in the scene
  101055. * @param x defines the x coordinate of the origin (on-screen)
  101056. * @param y defines the y coordinate of the origin (on-screen)
  101057. * @param result defines the ray where to store the picking ray
  101058. * @param camera defines the camera to use for the picking
  101059. * @returns the current scene
  101060. */
  101061. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  101062. /** Launch a ray to try to pick a mesh in the scene
  101063. * @param x position on screen
  101064. * @param y position on screen
  101065. * @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
  101066. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  101067. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101068. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101069. * @returns a PickingInfo
  101070. */
  101071. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101072. /** Use the given ray to pick a mesh in the scene
  101073. * @param ray The ray to use to pick meshes
  101074. * @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
  101075. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  101076. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101077. * @returns a PickingInfo
  101078. */
  101079. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101080. /**
  101081. * Launch a ray to try to pick a mesh in the scene
  101082. * @param x X position on screen
  101083. * @param y Y position on screen
  101084. * @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
  101085. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101086. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101087. * @returns an array of PickingInfo
  101088. */
  101089. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101090. /**
  101091. * Launch a ray to try to pick a mesh in the scene
  101092. * @param ray Ray to use
  101093. * @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
  101094. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101095. * @returns an array of PickingInfo
  101096. */
  101097. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101098. /**
  101099. * Force the value of meshUnderPointer
  101100. * @param mesh defines the mesh to use
  101101. */
  101102. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101103. /**
  101104. * Gets the mesh under the pointer
  101105. * @returns a Mesh or null if no mesh is under the pointer
  101106. */
  101107. getPointerOverMesh(): Nullable<AbstractMesh>;
  101108. /** @hidden */
  101109. _rebuildGeometries(): void;
  101110. /** @hidden */
  101111. _rebuildTextures(): void;
  101112. private _getByTags;
  101113. /**
  101114. * Get a list of meshes by tags
  101115. * @param tagsQuery defines the tags query to use
  101116. * @param forEach defines a predicate used to filter results
  101117. * @returns an array of Mesh
  101118. */
  101119. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  101120. /**
  101121. * Get a list of cameras by tags
  101122. * @param tagsQuery defines the tags query to use
  101123. * @param forEach defines a predicate used to filter results
  101124. * @returns an array of Camera
  101125. */
  101126. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  101127. /**
  101128. * Get a list of lights 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 Light
  101132. */
  101133. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  101134. /**
  101135. * Get a list of materials 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 Material
  101139. */
  101140. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  101141. /**
  101142. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101143. * This allowed control for front to back rendering or reversly depending of the special needs.
  101144. *
  101145. * @param renderingGroupId The rendering group id corresponding to its index
  101146. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101147. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101148. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101149. */
  101150. 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;
  101151. /**
  101152. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101153. *
  101154. * @param renderingGroupId The rendering group id corresponding to its index
  101155. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101156. * @param depth Automatically clears depth between groups if true and autoClear is true.
  101157. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  101158. */
  101159. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  101160. /**
  101161. * Gets the current auto clear configuration for one rendering group of the rendering
  101162. * manager.
  101163. * @param index the rendering group index to get the information for
  101164. * @returns The auto clear setup for the requested rendering group
  101165. */
  101166. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  101167. private _blockMaterialDirtyMechanism;
  101168. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  101169. blockMaterialDirtyMechanism: boolean;
  101170. /**
  101171. * Will flag all materials as dirty to trigger new shader compilation
  101172. * @param flag defines the flag used to specify which material part must be marked as dirty
  101173. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  101174. */
  101175. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  101176. /** @hidden */
  101177. _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;
  101178. /** @hidden */
  101179. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  101180. }
  101181. }
  101182. declare module BABYLON {
  101183. /**
  101184. * Set of assets to keep when moving a scene into an asset container.
  101185. */
  101186. export class KeepAssets extends AbstractScene {
  101187. }
  101188. /**
  101189. * Container with a set of assets that can be added or removed from a scene.
  101190. */
  101191. export class AssetContainer extends AbstractScene {
  101192. /**
  101193. * The scene the AssetContainer belongs to.
  101194. */
  101195. scene: Scene;
  101196. /**
  101197. * Instantiates an AssetContainer.
  101198. * @param scene The scene the AssetContainer belongs to.
  101199. */
  101200. constructor(scene: Scene);
  101201. /**
  101202. * Adds all the assets from the container to the scene.
  101203. */
  101204. addAllToScene(): void;
  101205. /**
  101206. * Removes all the assets in the container from the scene
  101207. */
  101208. removeAllFromScene(): void;
  101209. /**
  101210. * Disposes all the assets in the container
  101211. */
  101212. dispose(): void;
  101213. private _moveAssets;
  101214. /**
  101215. * Removes all the assets contained in the scene and adds them to the container.
  101216. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  101217. */
  101218. moveAllFromScene(keepAssets?: KeepAssets): void;
  101219. /**
  101220. * 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.
  101221. * @returns the root mesh
  101222. */
  101223. createRootMesh(): Mesh;
  101224. }
  101225. }
  101226. declare module BABYLON {
  101227. /**
  101228. * Defines how the parser contract is defined.
  101229. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  101230. */
  101231. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  101232. /**
  101233. * Defines how the individual parser contract is defined.
  101234. * These parser can parse an individual asset
  101235. */
  101236. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  101237. /**
  101238. * Base class of the scene acting as a container for the different elements composing a scene.
  101239. * This class is dynamically extended by the different components of the scene increasing
  101240. * flexibility and reducing coupling
  101241. */
  101242. export abstract class AbstractScene {
  101243. /**
  101244. * Stores the list of available parsers in the application.
  101245. */
  101246. private static _BabylonFileParsers;
  101247. /**
  101248. * Stores the list of available individual parsers in the application.
  101249. */
  101250. private static _IndividualBabylonFileParsers;
  101251. /**
  101252. * Adds a parser in the list of available ones
  101253. * @param name Defines the name of the parser
  101254. * @param parser Defines the parser to add
  101255. */
  101256. static AddParser(name: string, parser: BabylonFileParser): void;
  101257. /**
  101258. * Gets a general parser from the list of avaialble ones
  101259. * @param name Defines the name of the parser
  101260. * @returns the requested parser or null
  101261. */
  101262. static GetParser(name: string): Nullable<BabylonFileParser>;
  101263. /**
  101264. * Adds n individual parser in the list of available ones
  101265. * @param name Defines the name of the parser
  101266. * @param parser Defines the parser to add
  101267. */
  101268. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  101269. /**
  101270. * Gets an individual parser from the list of avaialble ones
  101271. * @param name Defines the name of the parser
  101272. * @returns the requested parser or null
  101273. */
  101274. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  101275. /**
  101276. * Parser json data and populate both a scene and its associated container object
  101277. * @param jsonData Defines the data to parse
  101278. * @param scene Defines the scene to parse the data for
  101279. * @param container Defines the container attached to the parsing sequence
  101280. * @param rootUrl Defines the root url of the data
  101281. */
  101282. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  101283. /**
  101284. * Gets the list of root nodes (ie. nodes with no parent)
  101285. */
  101286. rootNodes: Node[];
  101287. /** All of the cameras added to this scene
  101288. * @see http://doc.babylonjs.com/babylon101/cameras
  101289. */
  101290. cameras: Camera[];
  101291. /**
  101292. * All of the lights added to this scene
  101293. * @see http://doc.babylonjs.com/babylon101/lights
  101294. */
  101295. lights: Light[];
  101296. /**
  101297. * All of the (abstract) meshes added to this scene
  101298. */
  101299. meshes: AbstractMesh[];
  101300. /**
  101301. * The list of skeletons added to the scene
  101302. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101303. */
  101304. skeletons: Skeleton[];
  101305. /**
  101306. * All of the particle systems added to this scene
  101307. * @see http://doc.babylonjs.com/babylon101/particles
  101308. */
  101309. particleSystems: IParticleSystem[];
  101310. /**
  101311. * Gets a list of Animations associated with the scene
  101312. */
  101313. animations: Animation[];
  101314. /**
  101315. * All of the animation groups added to this scene
  101316. * @see http://doc.babylonjs.com/how_to/group
  101317. */
  101318. animationGroups: AnimationGroup[];
  101319. /**
  101320. * All of the multi-materials added to this scene
  101321. * @see http://doc.babylonjs.com/how_to/multi_materials
  101322. */
  101323. multiMaterials: MultiMaterial[];
  101324. /**
  101325. * All of the materials added to this scene
  101326. * In the context of a Scene, it is not supposed to be modified manually.
  101327. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  101328. * Note also that the order of the Material wihin the array is not significant and might change.
  101329. * @see http://doc.babylonjs.com/babylon101/materials
  101330. */
  101331. materials: Material[];
  101332. /**
  101333. * The list of morph target managers added to the scene
  101334. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  101335. */
  101336. morphTargetManagers: MorphTargetManager[];
  101337. /**
  101338. * The list of geometries used in the scene.
  101339. */
  101340. geometries: Geometry[];
  101341. /**
  101342. * All of the tranform nodes added to this scene
  101343. * In the context of a Scene, it is not supposed to be modified manually.
  101344. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  101345. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  101346. * @see http://doc.babylonjs.com/how_to/transformnode
  101347. */
  101348. transformNodes: TransformNode[];
  101349. /**
  101350. * ActionManagers available on the scene.
  101351. */
  101352. actionManagers: AbstractActionManager[];
  101353. /**
  101354. * Textures to keep.
  101355. */
  101356. textures: BaseTexture[];
  101357. /**
  101358. * Environment texture for the scene
  101359. */
  101360. environmentTexture: Nullable<BaseTexture>;
  101361. }
  101362. }
  101363. declare module BABYLON {
  101364. /**
  101365. * Interface used to define options for Sound class
  101366. */
  101367. export interface ISoundOptions {
  101368. /**
  101369. * Does the sound autoplay once loaded.
  101370. */
  101371. autoplay?: boolean;
  101372. /**
  101373. * Does the sound loop after it finishes playing once.
  101374. */
  101375. loop?: boolean;
  101376. /**
  101377. * Sound's volume
  101378. */
  101379. volume?: number;
  101380. /**
  101381. * Is it a spatial sound?
  101382. */
  101383. spatialSound?: boolean;
  101384. /**
  101385. * Maximum distance to hear that sound
  101386. */
  101387. maxDistance?: number;
  101388. /**
  101389. * Uses user defined attenuation function
  101390. */
  101391. useCustomAttenuation?: boolean;
  101392. /**
  101393. * Define the roll off factor of spatial sounds.
  101394. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101395. */
  101396. rolloffFactor?: number;
  101397. /**
  101398. * Define the reference distance the sound should be heard perfectly.
  101399. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101400. */
  101401. refDistance?: number;
  101402. /**
  101403. * Define the distance attenuation model the sound will follow.
  101404. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101405. */
  101406. distanceModel?: string;
  101407. /**
  101408. * Defines the playback speed (1 by default)
  101409. */
  101410. playbackRate?: number;
  101411. /**
  101412. * Defines if the sound is from a streaming source
  101413. */
  101414. streaming?: boolean;
  101415. /**
  101416. * Defines an optional length (in seconds) inside the sound file
  101417. */
  101418. length?: number;
  101419. /**
  101420. * Defines an optional offset (in seconds) inside the sound file
  101421. */
  101422. offset?: number;
  101423. /**
  101424. * If true, URLs will not be required to state the audio file codec to use.
  101425. */
  101426. skipCodecCheck?: boolean;
  101427. }
  101428. /**
  101429. * Defines a sound that can be played in the application.
  101430. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  101431. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101432. */
  101433. export class Sound {
  101434. /**
  101435. * The name of the sound in the scene.
  101436. */
  101437. name: string;
  101438. /**
  101439. * Does the sound autoplay once loaded.
  101440. */
  101441. autoplay: boolean;
  101442. /**
  101443. * Does the sound loop after it finishes playing once.
  101444. */
  101445. loop: boolean;
  101446. /**
  101447. * Does the sound use a custom attenuation curve to simulate the falloff
  101448. * happening when the source gets further away from the camera.
  101449. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101450. */
  101451. useCustomAttenuation: boolean;
  101452. /**
  101453. * The sound track id this sound belongs to.
  101454. */
  101455. soundTrackId: number;
  101456. /**
  101457. * Is this sound currently played.
  101458. */
  101459. isPlaying: boolean;
  101460. /**
  101461. * Is this sound currently paused.
  101462. */
  101463. isPaused: boolean;
  101464. /**
  101465. * Does this sound enables spatial sound.
  101466. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101467. */
  101468. spatialSound: boolean;
  101469. /**
  101470. * Define the reference distance the sound should be heard perfectly.
  101471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101472. */
  101473. refDistance: number;
  101474. /**
  101475. * Define the roll off factor of spatial sounds.
  101476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101477. */
  101478. rolloffFactor: number;
  101479. /**
  101480. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  101481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101482. */
  101483. maxDistance: number;
  101484. /**
  101485. * Define the distance attenuation model the sound will follow.
  101486. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101487. */
  101488. distanceModel: string;
  101489. /**
  101490. * @hidden
  101491. * Back Compat
  101492. **/
  101493. onended: () => any;
  101494. /**
  101495. * Observable event when the current playing sound finishes.
  101496. */
  101497. onEndedObservable: Observable<Sound>;
  101498. private _panningModel;
  101499. private _playbackRate;
  101500. private _streaming;
  101501. private _startTime;
  101502. private _startOffset;
  101503. private _position;
  101504. /** @hidden */
  101505. _positionInEmitterSpace: boolean;
  101506. private _localDirection;
  101507. private _volume;
  101508. private _isReadyToPlay;
  101509. private _isDirectional;
  101510. private _readyToPlayCallback;
  101511. private _audioBuffer;
  101512. private _soundSource;
  101513. private _streamingSource;
  101514. private _soundPanner;
  101515. private _soundGain;
  101516. private _inputAudioNode;
  101517. private _outputAudioNode;
  101518. private _coneInnerAngle;
  101519. private _coneOuterAngle;
  101520. private _coneOuterGain;
  101521. private _scene;
  101522. private _connectedTransformNode;
  101523. private _customAttenuationFunction;
  101524. private _registerFunc;
  101525. private _isOutputConnected;
  101526. private _htmlAudioElement;
  101527. private _urlType;
  101528. private _length?;
  101529. private _offset?;
  101530. /** @hidden */
  101531. static _SceneComponentInitialization: (scene: Scene) => void;
  101532. /**
  101533. * Create a sound and attach it to a scene
  101534. * @param name Name of your sound
  101535. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  101536. * @param scene defines the scene the sound belongs to
  101537. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  101538. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  101539. */
  101540. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  101541. /**
  101542. * Release the sound and its associated resources
  101543. */
  101544. dispose(): void;
  101545. /**
  101546. * Gets if the sounds is ready to be played or not.
  101547. * @returns true if ready, otherwise false
  101548. */
  101549. isReady(): boolean;
  101550. private _soundLoaded;
  101551. /**
  101552. * Sets the data of the sound from an audiobuffer
  101553. * @param audioBuffer The audioBuffer containing the data
  101554. */
  101555. setAudioBuffer(audioBuffer: AudioBuffer): void;
  101556. /**
  101557. * Updates the current sounds options such as maxdistance, loop...
  101558. * @param options A JSON object containing values named as the object properties
  101559. */
  101560. updateOptions(options: ISoundOptions): void;
  101561. private _createSpatialParameters;
  101562. private _updateSpatialParameters;
  101563. /**
  101564. * Switch the panning model to HRTF:
  101565. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101566. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101567. */
  101568. switchPanningModelToHRTF(): void;
  101569. /**
  101570. * Switch the panning model to Equal Power:
  101571. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101572. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101573. */
  101574. switchPanningModelToEqualPower(): void;
  101575. private _switchPanningModel;
  101576. /**
  101577. * Connect this sound to a sound track audio node like gain...
  101578. * @param soundTrackAudioNode the sound track audio node to connect to
  101579. */
  101580. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  101581. /**
  101582. * Transform this sound into a directional source
  101583. * @param coneInnerAngle Size of the inner cone in degree
  101584. * @param coneOuterAngle Size of the outer cone in degree
  101585. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  101586. */
  101587. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  101588. /**
  101589. * Gets or sets the inner angle for the directional cone.
  101590. */
  101591. /**
  101592. * Gets or sets the inner angle for the directional cone.
  101593. */
  101594. directionalConeInnerAngle: number;
  101595. /**
  101596. * Gets or sets the outer angle for the directional cone.
  101597. */
  101598. /**
  101599. * Gets or sets the outer angle for the directional cone.
  101600. */
  101601. directionalConeOuterAngle: number;
  101602. /**
  101603. * Sets the position of the emitter if spatial sound is enabled
  101604. * @param newPosition Defines the new posisiton
  101605. */
  101606. setPosition(newPosition: Vector3): void;
  101607. /**
  101608. * Sets the local direction of the emitter if spatial sound is enabled
  101609. * @param newLocalDirection Defines the new local direction
  101610. */
  101611. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  101612. private _updateDirection;
  101613. /** @hidden */
  101614. updateDistanceFromListener(): void;
  101615. /**
  101616. * Sets a new custom attenuation function for the sound.
  101617. * @param callback Defines the function used for the attenuation
  101618. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101619. */
  101620. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  101621. /**
  101622. * Play the sound
  101623. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  101624. * @param offset (optional) Start the sound at a specific time in seconds
  101625. * @param length (optional) Sound duration (in seconds)
  101626. */
  101627. play(time?: number, offset?: number, length?: number): void;
  101628. private _onended;
  101629. /**
  101630. * Stop the sound
  101631. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  101632. */
  101633. stop(time?: number): void;
  101634. /**
  101635. * Put the sound in pause
  101636. */
  101637. pause(): void;
  101638. /**
  101639. * Sets a dedicated volume for this sounds
  101640. * @param newVolume Define the new volume of the sound
  101641. * @param time Define time for gradual change to new volume
  101642. */
  101643. setVolume(newVolume: number, time?: number): void;
  101644. /**
  101645. * Set the sound play back rate
  101646. * @param newPlaybackRate Define the playback rate the sound should be played at
  101647. */
  101648. setPlaybackRate(newPlaybackRate: number): void;
  101649. /**
  101650. * Gets the volume of the sound.
  101651. * @returns the volume of the sound
  101652. */
  101653. getVolume(): number;
  101654. /**
  101655. * Attach the sound to a dedicated mesh
  101656. * @param transformNode The transform node to connect the sound with
  101657. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  101658. */
  101659. attachToMesh(transformNode: TransformNode): void;
  101660. /**
  101661. * Detach the sound from the previously attached mesh
  101662. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  101663. */
  101664. detachFromMesh(): void;
  101665. private _onRegisterAfterWorldMatrixUpdate;
  101666. /**
  101667. * Clone the current sound in the scene.
  101668. * @returns the new sound clone
  101669. */
  101670. clone(): Nullable<Sound>;
  101671. /**
  101672. * Gets the current underlying audio buffer containing the data
  101673. * @returns the audio buffer
  101674. */
  101675. getAudioBuffer(): Nullable<AudioBuffer>;
  101676. /**
  101677. * Serializes the Sound in a JSON representation
  101678. * @returns the JSON representation of the sound
  101679. */
  101680. serialize(): any;
  101681. /**
  101682. * Parse a JSON representation of a sound to innstantiate in a given scene
  101683. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  101684. * @param scene Define the scene the new parsed sound should be created in
  101685. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  101686. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  101687. * @returns the newly parsed sound
  101688. */
  101689. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  101690. }
  101691. }
  101692. declare module BABYLON {
  101693. /**
  101694. * This defines an action helpful to play a defined sound on a triggered action.
  101695. */
  101696. export class PlaySoundAction extends Action {
  101697. private _sound;
  101698. /**
  101699. * Instantiate the action
  101700. * @param triggerOptions defines the trigger options
  101701. * @param sound defines the sound to play
  101702. * @param condition defines the trigger related conditions
  101703. */
  101704. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  101705. /** @hidden */
  101706. _prepare(): void;
  101707. /**
  101708. * Execute the action and play the sound.
  101709. */
  101710. execute(): void;
  101711. /**
  101712. * Serializes the actions and its related information.
  101713. * @param parent defines the object to serialize in
  101714. * @returns the serialized object
  101715. */
  101716. serialize(parent: any): any;
  101717. }
  101718. /**
  101719. * This defines an action helpful to stop a defined sound on a triggered action.
  101720. */
  101721. export class StopSoundAction extends Action {
  101722. private _sound;
  101723. /**
  101724. * Instantiate the action
  101725. * @param triggerOptions defines the trigger options
  101726. * @param sound defines the sound to stop
  101727. * @param condition defines the trigger related conditions
  101728. */
  101729. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  101730. /** @hidden */
  101731. _prepare(): void;
  101732. /**
  101733. * Execute the action and stop the sound.
  101734. */
  101735. execute(): void;
  101736. /**
  101737. * Serializes the actions and its related information.
  101738. * @param parent defines the object to serialize in
  101739. * @returns the serialized object
  101740. */
  101741. serialize(parent: any): any;
  101742. }
  101743. }
  101744. declare module BABYLON {
  101745. /**
  101746. * This defines an action responsible to change the value of a property
  101747. * by interpolating between its current value and the newly set one once triggered.
  101748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101749. */
  101750. export class InterpolateValueAction extends Action {
  101751. /**
  101752. * Defines the path of the property where the value should be interpolated
  101753. */
  101754. propertyPath: string;
  101755. /**
  101756. * Defines the target value at the end of the interpolation.
  101757. */
  101758. value: any;
  101759. /**
  101760. * Defines the time it will take for the property to interpolate to the value.
  101761. */
  101762. duration: number;
  101763. /**
  101764. * Defines if the other scene animations should be stopped when the action has been triggered
  101765. */
  101766. stopOtherAnimations?: boolean;
  101767. /**
  101768. * Defines a callback raised once the interpolation animation has been done.
  101769. */
  101770. onInterpolationDone?: () => void;
  101771. /**
  101772. * Observable triggered once the interpolation animation has been done.
  101773. */
  101774. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  101775. private _target;
  101776. private _effectiveTarget;
  101777. private _property;
  101778. /**
  101779. * Instantiate the action
  101780. * @param triggerOptions defines the trigger options
  101781. * @param target defines the object containing the value to interpolate
  101782. * @param propertyPath defines the path to the property in the target object
  101783. * @param value defines the target value at the end of the interpolation
  101784. * @param duration deines the time it will take for the property to interpolate to the value.
  101785. * @param condition defines the trigger related conditions
  101786. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  101787. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  101788. */
  101789. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  101790. /** @hidden */
  101791. _prepare(): void;
  101792. /**
  101793. * Execute the action starts the value interpolation.
  101794. */
  101795. execute(): void;
  101796. /**
  101797. * Serializes the actions and its related information.
  101798. * @param parent defines the object to serialize in
  101799. * @returns the serialized object
  101800. */
  101801. serialize(parent: any): any;
  101802. }
  101803. }
  101804. declare module BABYLON {
  101805. /**
  101806. * Options allowed during the creation of a sound track.
  101807. */
  101808. export interface ISoundTrackOptions {
  101809. /**
  101810. * The volume the sound track should take during creation
  101811. */
  101812. volume?: number;
  101813. /**
  101814. * Define if the sound track is the main sound track of the scene
  101815. */
  101816. mainTrack?: boolean;
  101817. }
  101818. /**
  101819. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  101820. * It will be also used in a future release to apply effects on a specific track.
  101821. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101822. */
  101823. export class SoundTrack {
  101824. /**
  101825. * The unique identifier of the sound track in the scene.
  101826. */
  101827. id: number;
  101828. /**
  101829. * The list of sounds included in the sound track.
  101830. */
  101831. soundCollection: Array<Sound>;
  101832. private _outputAudioNode;
  101833. private _scene;
  101834. private _isMainTrack;
  101835. private _connectedAnalyser;
  101836. private _options;
  101837. private _isInitialized;
  101838. /**
  101839. * Creates a new sound track.
  101840. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101841. * @param scene Define the scene the sound track belongs to
  101842. * @param options
  101843. */
  101844. constructor(scene: Scene, options?: ISoundTrackOptions);
  101845. private _initializeSoundTrackAudioGraph;
  101846. /**
  101847. * Release the sound track and its associated resources
  101848. */
  101849. dispose(): void;
  101850. /**
  101851. * Adds a sound to this sound track
  101852. * @param sound define the cound to add
  101853. * @ignoreNaming
  101854. */
  101855. AddSound(sound: Sound): void;
  101856. /**
  101857. * Removes a sound to this sound track
  101858. * @param sound define the cound to remove
  101859. * @ignoreNaming
  101860. */
  101861. RemoveSound(sound: Sound): void;
  101862. /**
  101863. * Set a global volume for the full sound track.
  101864. * @param newVolume Define the new volume of the sound track
  101865. */
  101866. setVolume(newVolume: number): void;
  101867. /**
  101868. * Switch the panning model to HRTF:
  101869. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101870. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101871. */
  101872. switchPanningModelToHRTF(): void;
  101873. /**
  101874. * Switch the panning model to Equal Power:
  101875. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101876. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101877. */
  101878. switchPanningModelToEqualPower(): void;
  101879. /**
  101880. * Connect the sound track to an audio analyser allowing some amazing
  101881. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  101882. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  101883. * @param analyser The analyser to connect to the engine
  101884. */
  101885. connectToAnalyser(analyser: Analyser): void;
  101886. }
  101887. }
  101888. declare module BABYLON {
  101889. interface AbstractScene {
  101890. /**
  101891. * The list of sounds used in the scene.
  101892. */
  101893. sounds: Nullable<Array<Sound>>;
  101894. }
  101895. interface Scene {
  101896. /**
  101897. * @hidden
  101898. * Backing field
  101899. */
  101900. _mainSoundTrack: SoundTrack;
  101901. /**
  101902. * The main sound track played by the scene.
  101903. * It cotains your primary collection of sounds.
  101904. */
  101905. mainSoundTrack: SoundTrack;
  101906. /**
  101907. * The list of sound tracks added to the scene
  101908. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101909. */
  101910. soundTracks: Nullable<Array<SoundTrack>>;
  101911. /**
  101912. * Gets a sound using a given name
  101913. * @param name defines the name to search for
  101914. * @return the found sound or null if not found at all.
  101915. */
  101916. getSoundByName(name: string): Nullable<Sound>;
  101917. /**
  101918. * Gets or sets if audio support is enabled
  101919. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101920. */
  101921. audioEnabled: boolean;
  101922. /**
  101923. * Gets or sets if audio will be output to headphones
  101924. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101925. */
  101926. headphone: boolean;
  101927. /**
  101928. * Gets or sets custom audio listener position provider
  101929. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101930. */
  101931. audioListenerPositionProvider: Nullable<() => Vector3>;
  101932. }
  101933. /**
  101934. * Defines the sound scene component responsible to manage any sounds
  101935. * in a given scene.
  101936. */
  101937. export class AudioSceneComponent implements ISceneSerializableComponent {
  101938. /**
  101939. * The component name helpfull to identify the component in the list of scene components.
  101940. */
  101941. readonly name: string;
  101942. /**
  101943. * The scene the component belongs to.
  101944. */
  101945. scene: Scene;
  101946. private _audioEnabled;
  101947. /**
  101948. * Gets whether audio is enabled or not.
  101949. * Please use related enable/disable method to switch state.
  101950. */
  101951. readonly audioEnabled: boolean;
  101952. private _headphone;
  101953. /**
  101954. * Gets whether audio is outputing to headphone or not.
  101955. * Please use the according Switch methods to change output.
  101956. */
  101957. readonly headphone: boolean;
  101958. private _audioListenerPositionProvider;
  101959. /**
  101960. * Gets the current audio listener position provider
  101961. */
  101962. /**
  101963. * Sets a custom listener position for all sounds in the scene
  101964. * By default, this is the position of the first active camera
  101965. */
  101966. audioListenerPositionProvider: Nullable<() => Vector3>;
  101967. /**
  101968. * Creates a new instance of the component for the given scene
  101969. * @param scene Defines the scene to register the component in
  101970. */
  101971. constructor(scene: Scene);
  101972. /**
  101973. * Registers the component in a given scene
  101974. */
  101975. register(): void;
  101976. /**
  101977. * Rebuilds the elements related to this component in case of
  101978. * context lost for instance.
  101979. */
  101980. rebuild(): void;
  101981. /**
  101982. * Serializes the component data to the specified json object
  101983. * @param serializationObject The object to serialize to
  101984. */
  101985. serialize(serializationObject: any): void;
  101986. /**
  101987. * Adds all the elements from the container to the scene
  101988. * @param container the container holding the elements
  101989. */
  101990. addFromContainer(container: AbstractScene): void;
  101991. /**
  101992. * Removes all the elements in the container from the scene
  101993. * @param container contains the elements to remove
  101994. * @param dispose if the removed element should be disposed (default: false)
  101995. */
  101996. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  101997. /**
  101998. * Disposes the component and the associated ressources.
  101999. */
  102000. dispose(): void;
  102001. /**
  102002. * Disables audio in the associated scene.
  102003. */
  102004. disableAudio(): void;
  102005. /**
  102006. * Enables audio in the associated scene.
  102007. */
  102008. enableAudio(): void;
  102009. /**
  102010. * Switch audio to headphone output.
  102011. */
  102012. switchAudioModeForHeadphones(): void;
  102013. /**
  102014. * Switch audio to normal speakers.
  102015. */
  102016. switchAudioModeForNormalSpeakers(): void;
  102017. private _afterRender;
  102018. }
  102019. }
  102020. declare module BABYLON {
  102021. /**
  102022. * Wraps one or more Sound objects and selects one with random weight for playback.
  102023. */
  102024. export class WeightedSound {
  102025. /** When true a Sound will be selected and played when the current playing Sound completes. */
  102026. loop: boolean;
  102027. private _coneInnerAngle;
  102028. private _coneOuterAngle;
  102029. private _volume;
  102030. /** A Sound is currently playing. */
  102031. isPlaying: boolean;
  102032. /** A Sound is currently paused. */
  102033. isPaused: boolean;
  102034. private _sounds;
  102035. private _weights;
  102036. private _currentIndex?;
  102037. /**
  102038. * Creates a new WeightedSound from the list of sounds given.
  102039. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  102040. * @param sounds Array of Sounds that will be selected from.
  102041. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  102042. */
  102043. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  102044. /**
  102045. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  102046. */
  102047. /**
  102048. * The size of cone in degress for a directional sound in which there will be no attenuation.
  102049. */
  102050. directionalConeInnerAngle: number;
  102051. /**
  102052. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102053. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102054. */
  102055. /**
  102056. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102057. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102058. */
  102059. directionalConeOuterAngle: number;
  102060. /**
  102061. * Playback volume.
  102062. */
  102063. /**
  102064. * Playback volume.
  102065. */
  102066. volume: number;
  102067. private _onended;
  102068. /**
  102069. * Suspend playback
  102070. */
  102071. pause(): void;
  102072. /**
  102073. * Stop playback
  102074. */
  102075. stop(): void;
  102076. /**
  102077. * Start playback.
  102078. * @param startOffset Position the clip head at a specific time in seconds.
  102079. */
  102080. play(startOffset?: number): void;
  102081. }
  102082. }
  102083. declare module BABYLON {
  102084. /**
  102085. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  102086. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102087. */
  102088. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  102089. /**
  102090. * Gets the name of the behavior.
  102091. */
  102092. readonly name: string;
  102093. /**
  102094. * The easing function used by animations
  102095. */
  102096. static EasingFunction: BackEase;
  102097. /**
  102098. * The easing mode used by animations
  102099. */
  102100. static EasingMode: number;
  102101. /**
  102102. * The duration of the animation, in milliseconds
  102103. */
  102104. transitionDuration: number;
  102105. /**
  102106. * Length of the distance animated by the transition when lower radius is reached
  102107. */
  102108. lowerRadiusTransitionRange: number;
  102109. /**
  102110. * Length of the distance animated by the transition when upper radius is reached
  102111. */
  102112. upperRadiusTransitionRange: number;
  102113. private _autoTransitionRange;
  102114. /**
  102115. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102116. */
  102117. /**
  102118. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102119. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  102120. */
  102121. autoTransitionRange: boolean;
  102122. private _attachedCamera;
  102123. private _onAfterCheckInputsObserver;
  102124. private _onMeshTargetChangedObserver;
  102125. /**
  102126. * Initializes the behavior.
  102127. */
  102128. init(): void;
  102129. /**
  102130. * Attaches the behavior to its arc rotate camera.
  102131. * @param camera Defines the camera to attach the behavior to
  102132. */
  102133. attach(camera: ArcRotateCamera): void;
  102134. /**
  102135. * Detaches the behavior from its current arc rotate camera.
  102136. */
  102137. detach(): void;
  102138. private _radiusIsAnimating;
  102139. private _radiusBounceTransition;
  102140. private _animatables;
  102141. private _cachedWheelPrecision;
  102142. /**
  102143. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  102144. * @param radiusLimit The limit to check against.
  102145. * @return Bool to indicate if at limit.
  102146. */
  102147. private _isRadiusAtLimit;
  102148. /**
  102149. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  102150. * @param radiusDelta The delta by which to animate to. Can be negative.
  102151. */
  102152. private _applyBoundRadiusAnimation;
  102153. /**
  102154. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  102155. */
  102156. protected _clearAnimationLocks(): void;
  102157. /**
  102158. * Stops and removes all animations that have been applied to the camera
  102159. */
  102160. stopAllAnimations(): void;
  102161. }
  102162. }
  102163. declare module BABYLON {
  102164. /**
  102165. * 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.
  102166. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102167. */
  102168. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  102169. /**
  102170. * Gets the name of the behavior.
  102171. */
  102172. readonly name: string;
  102173. private _mode;
  102174. private _radiusScale;
  102175. private _positionScale;
  102176. private _defaultElevation;
  102177. private _elevationReturnTime;
  102178. private _elevationReturnWaitTime;
  102179. private _zoomStopsAnimation;
  102180. private _framingTime;
  102181. /**
  102182. * The easing function used by animations
  102183. */
  102184. static EasingFunction: ExponentialEase;
  102185. /**
  102186. * The easing mode used by animations
  102187. */
  102188. static EasingMode: number;
  102189. /**
  102190. * Sets the current mode used by the behavior
  102191. */
  102192. /**
  102193. * Gets current mode used by the behavior.
  102194. */
  102195. mode: number;
  102196. /**
  102197. * Sets the scale applied to the radius (1 by default)
  102198. */
  102199. /**
  102200. * Gets the scale applied to the radius
  102201. */
  102202. radiusScale: number;
  102203. /**
  102204. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102205. */
  102206. /**
  102207. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102208. */
  102209. positionScale: number;
  102210. /**
  102211. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102212. * behaviour is triggered, in radians.
  102213. */
  102214. /**
  102215. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102216. * behaviour is triggered, in radians.
  102217. */
  102218. defaultElevation: number;
  102219. /**
  102220. * Sets the time (in milliseconds) taken to return to the default beta position.
  102221. * Negative value indicates camera should not return to default.
  102222. */
  102223. /**
  102224. * Gets the time (in milliseconds) taken to return to the default beta position.
  102225. * Negative value indicates camera should not return to default.
  102226. */
  102227. elevationReturnTime: number;
  102228. /**
  102229. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102230. */
  102231. /**
  102232. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102233. */
  102234. elevationReturnWaitTime: number;
  102235. /**
  102236. * Sets the flag that indicates if user zooming should stop animation.
  102237. */
  102238. /**
  102239. * Gets the flag that indicates if user zooming should stop animation.
  102240. */
  102241. zoomStopsAnimation: boolean;
  102242. /**
  102243. * Sets the transition time when framing the mesh, in milliseconds
  102244. */
  102245. /**
  102246. * Gets the transition time when framing the mesh, in milliseconds
  102247. */
  102248. framingTime: number;
  102249. /**
  102250. * Define if the behavior should automatically change the configured
  102251. * camera limits and sensibilities.
  102252. */
  102253. autoCorrectCameraLimitsAndSensibility: boolean;
  102254. private _onPrePointerObservableObserver;
  102255. private _onAfterCheckInputsObserver;
  102256. private _onMeshTargetChangedObserver;
  102257. private _attachedCamera;
  102258. private _isPointerDown;
  102259. private _lastInteractionTime;
  102260. /**
  102261. * Initializes the behavior.
  102262. */
  102263. init(): void;
  102264. /**
  102265. * Attaches the behavior to its arc rotate camera.
  102266. * @param camera Defines the camera to attach the behavior to
  102267. */
  102268. attach(camera: ArcRotateCamera): void;
  102269. /**
  102270. * Detaches the behavior from its current arc rotate camera.
  102271. */
  102272. detach(): void;
  102273. private _animatables;
  102274. private _betaIsAnimating;
  102275. private _betaTransition;
  102276. private _radiusTransition;
  102277. private _vectorTransition;
  102278. /**
  102279. * Targets the given mesh and updates zoom level accordingly.
  102280. * @param mesh The mesh to target.
  102281. * @param radius Optional. If a cached radius position already exists, overrides default.
  102282. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102283. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102284. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102285. */
  102286. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102287. /**
  102288. * Targets the given mesh with its children and updates zoom level accordingly.
  102289. * @param mesh The mesh to target.
  102290. * @param radius Optional. If a cached radius position already exists, overrides default.
  102291. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102292. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102293. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102294. */
  102295. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102296. /**
  102297. * Targets the given meshes with their children and updates zoom level accordingly.
  102298. * @param meshes The mesh to target.
  102299. * @param radius Optional. If a cached radius position already exists, overrides default.
  102300. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102301. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102302. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102303. */
  102304. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102305. /**
  102306. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  102307. * @param minimumWorld Determines the smaller position of the bounding box extend
  102308. * @param maximumWorld Determines the bigger position of the bounding box extend
  102309. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102310. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102311. */
  102312. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102313. /**
  102314. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  102315. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  102316. * frustum width.
  102317. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  102318. * to fully enclose the mesh in the viewing frustum.
  102319. */
  102320. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  102321. /**
  102322. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  102323. * is automatically returned to its default position (expected to be above ground plane).
  102324. */
  102325. private _maintainCameraAboveGround;
  102326. /**
  102327. * Returns the frustum slope based on the canvas ratio and camera FOV
  102328. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  102329. */
  102330. private _getFrustumSlope;
  102331. /**
  102332. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  102333. */
  102334. private _clearAnimationLocks;
  102335. /**
  102336. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102337. */
  102338. private _applyUserInteraction;
  102339. /**
  102340. * Stops and removes all animations that have been applied to the camera
  102341. */
  102342. stopAllAnimations(): void;
  102343. /**
  102344. * Gets a value indicating if the user is moving the camera
  102345. */
  102346. readonly isUserIsMoving: boolean;
  102347. /**
  102348. * The camera can move all the way towards the mesh.
  102349. */
  102350. static IgnoreBoundsSizeMode: number;
  102351. /**
  102352. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  102353. */
  102354. static FitFrustumSidesMode: number;
  102355. }
  102356. }
  102357. declare module BABYLON {
  102358. /**
  102359. * Base class for Camera Pointer Inputs.
  102360. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  102361. * for example usage.
  102362. */
  102363. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  102364. /**
  102365. * Defines the camera the input is attached to.
  102366. */
  102367. abstract camera: Camera;
  102368. /**
  102369. * Whether keyboard modifier keys are pressed at time of last mouse event.
  102370. */
  102371. protected _altKey: boolean;
  102372. protected _ctrlKey: boolean;
  102373. protected _metaKey: boolean;
  102374. protected _shiftKey: boolean;
  102375. /**
  102376. * Which mouse buttons were pressed at time of last mouse event.
  102377. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  102378. */
  102379. protected _buttonsPressed: number;
  102380. /**
  102381. * Defines the buttons associated with the input to handle camera move.
  102382. */
  102383. buttons: number[];
  102384. /**
  102385. * Attach the input controls to a specific dom element to get the input from.
  102386. * @param element Defines the element the controls should be listened from
  102387. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102388. */
  102389. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102390. /**
  102391. * Detach the current controls from the specified dom element.
  102392. * @param element Defines the element to stop listening the inputs from
  102393. */
  102394. detachControl(element: Nullable<HTMLElement>): void;
  102395. /**
  102396. * Gets the class name of the current input.
  102397. * @returns the class name
  102398. */
  102399. getClassName(): string;
  102400. /**
  102401. * Get the friendly name associated with the input class.
  102402. * @returns the input friendly name
  102403. */
  102404. getSimpleName(): string;
  102405. /**
  102406. * Called on pointer POINTERDOUBLETAP event.
  102407. * Override this method to provide functionality on POINTERDOUBLETAP event.
  102408. */
  102409. protected onDoubleTap(type: string): void;
  102410. /**
  102411. * Called on pointer POINTERMOVE event if only a single touch is active.
  102412. * Override this method to provide functionality.
  102413. */
  102414. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102415. /**
  102416. * Called on pointer POINTERMOVE event if multiple touches are active.
  102417. * Override this method to provide functionality.
  102418. */
  102419. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102420. /**
  102421. * Called on JS contextmenu event.
  102422. * Override this method to provide functionality.
  102423. */
  102424. protected onContextMenu(evt: PointerEvent): void;
  102425. /**
  102426. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102427. * press.
  102428. * Override this method to provide functionality.
  102429. */
  102430. protected onButtonDown(evt: PointerEvent): void;
  102431. /**
  102432. * Called each time a new POINTERUP event occurs. Ie, for each button
  102433. * release.
  102434. * Override this method to provide functionality.
  102435. */
  102436. protected onButtonUp(evt: PointerEvent): void;
  102437. /**
  102438. * Called when window becomes inactive.
  102439. * Override this method to provide functionality.
  102440. */
  102441. protected onLostFocus(): void;
  102442. private _pointerInput;
  102443. private _observer;
  102444. private _onLostFocus;
  102445. private pointA;
  102446. private pointB;
  102447. }
  102448. }
  102449. declare module BABYLON {
  102450. /**
  102451. * Manage the pointers inputs to control an arc rotate camera.
  102452. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102453. */
  102454. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  102455. /**
  102456. * Defines the camera the input is attached to.
  102457. */
  102458. camera: ArcRotateCamera;
  102459. /**
  102460. * Gets the class name of the current input.
  102461. * @returns the class name
  102462. */
  102463. getClassName(): string;
  102464. /**
  102465. * Defines the buttons associated with the input to handle camera move.
  102466. */
  102467. buttons: number[];
  102468. /**
  102469. * Defines the pointer angular sensibility along the X axis or how fast is
  102470. * the camera rotating.
  102471. */
  102472. angularSensibilityX: number;
  102473. /**
  102474. * Defines the pointer angular sensibility along the Y axis or how fast is
  102475. * the camera rotating.
  102476. */
  102477. angularSensibilityY: number;
  102478. /**
  102479. * Defines the pointer pinch precision or how fast is the camera zooming.
  102480. */
  102481. pinchPrecision: number;
  102482. /**
  102483. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  102484. * from 0.
  102485. * It defines the percentage of current camera.radius to use as delta when
  102486. * pinch zoom is used.
  102487. */
  102488. pinchDeltaPercentage: number;
  102489. /**
  102490. * Defines the pointer panning sensibility or how fast is the camera moving.
  102491. */
  102492. panningSensibility: number;
  102493. /**
  102494. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  102495. */
  102496. multiTouchPanning: boolean;
  102497. /**
  102498. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  102499. * zoom (pinch) through multitouch.
  102500. */
  102501. multiTouchPanAndZoom: boolean;
  102502. /**
  102503. * Revers pinch action direction.
  102504. */
  102505. pinchInwards: boolean;
  102506. private _isPanClick;
  102507. private _twoFingerActivityCount;
  102508. private _isPinching;
  102509. /**
  102510. * Called on pointer POINTERMOVE event if only a single touch is active.
  102511. */
  102512. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102513. /**
  102514. * Called on pointer POINTERDOUBLETAP event.
  102515. */
  102516. protected onDoubleTap(type: string): void;
  102517. /**
  102518. * Called on pointer POINTERMOVE event if multiple touches are active.
  102519. */
  102520. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102521. /**
  102522. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102523. * press.
  102524. */
  102525. protected onButtonDown(evt: PointerEvent): void;
  102526. /**
  102527. * Called each time a new POINTERUP event occurs. Ie, for each button
  102528. * release.
  102529. */
  102530. protected onButtonUp(evt: PointerEvent): void;
  102531. /**
  102532. * Called when window becomes inactive.
  102533. */
  102534. protected onLostFocus(): void;
  102535. }
  102536. }
  102537. declare module BABYLON {
  102538. /**
  102539. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  102540. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102541. */
  102542. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  102543. /**
  102544. * Defines the camera the input is attached to.
  102545. */
  102546. camera: ArcRotateCamera;
  102547. /**
  102548. * Defines the list of key codes associated with the up action (increase alpha)
  102549. */
  102550. keysUp: number[];
  102551. /**
  102552. * Defines the list of key codes associated with the down action (decrease alpha)
  102553. */
  102554. keysDown: number[];
  102555. /**
  102556. * Defines the list of key codes associated with the left action (increase beta)
  102557. */
  102558. keysLeft: number[];
  102559. /**
  102560. * Defines the list of key codes associated with the right action (decrease beta)
  102561. */
  102562. keysRight: number[];
  102563. /**
  102564. * Defines the list of key codes associated with the reset action.
  102565. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  102566. */
  102567. keysReset: number[];
  102568. /**
  102569. * Defines the panning sensibility of the inputs.
  102570. * (How fast is the camera paning)
  102571. */
  102572. panningSensibility: number;
  102573. /**
  102574. * Defines the zooming sensibility of the inputs.
  102575. * (How fast is the camera zooming)
  102576. */
  102577. zoomingSensibility: number;
  102578. /**
  102579. * Defines wether maintaining the alt key down switch the movement mode from
  102580. * orientation to zoom.
  102581. */
  102582. useAltToZoom: boolean;
  102583. /**
  102584. * Rotation speed of the camera
  102585. */
  102586. angularSpeed: number;
  102587. private _keys;
  102588. private _ctrlPressed;
  102589. private _altPressed;
  102590. private _onCanvasBlurObserver;
  102591. private _onKeyboardObserver;
  102592. private _engine;
  102593. private _scene;
  102594. /**
  102595. * Attach the input controls to a specific dom element to get the input from.
  102596. * @param element Defines the element the controls should be listened from
  102597. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102598. */
  102599. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102600. /**
  102601. * Detach the current controls from the specified dom element.
  102602. * @param element Defines the element to stop listening the inputs from
  102603. */
  102604. detachControl(element: Nullable<HTMLElement>): void;
  102605. /**
  102606. * Update the current camera state depending on the inputs that have been used this frame.
  102607. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102608. */
  102609. checkInputs(): void;
  102610. /**
  102611. * Gets the class name of the current intput.
  102612. * @returns the class name
  102613. */
  102614. getClassName(): string;
  102615. /**
  102616. * Get the friendly name associated with the input class.
  102617. * @returns the input friendly name
  102618. */
  102619. getSimpleName(): string;
  102620. }
  102621. }
  102622. declare module BABYLON {
  102623. /**
  102624. * Manage the mouse wheel inputs to control an arc rotate camera.
  102625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102626. */
  102627. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  102628. /**
  102629. * Defines the camera the input is attached to.
  102630. */
  102631. camera: ArcRotateCamera;
  102632. /**
  102633. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  102634. */
  102635. wheelPrecision: number;
  102636. /**
  102637. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  102638. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  102639. */
  102640. wheelDeltaPercentage: number;
  102641. private _wheel;
  102642. private _observer;
  102643. private computeDeltaFromMouseWheelLegacyEvent;
  102644. /**
  102645. * Attach the input controls to a specific dom element to get the input from.
  102646. * @param element Defines the element the controls should be listened from
  102647. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102648. */
  102649. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102650. /**
  102651. * Detach the current controls from the specified dom element.
  102652. * @param element Defines the element to stop listening the inputs from
  102653. */
  102654. detachControl(element: Nullable<HTMLElement>): void;
  102655. /**
  102656. * Gets the class name of the current intput.
  102657. * @returns the class name
  102658. */
  102659. getClassName(): string;
  102660. /**
  102661. * Get the friendly name associated with the input class.
  102662. * @returns the input friendly name
  102663. */
  102664. getSimpleName(): string;
  102665. }
  102666. }
  102667. declare module BABYLON {
  102668. /**
  102669. * Default Inputs manager for the ArcRotateCamera.
  102670. * It groups all the default supported inputs for ease of use.
  102671. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102672. */
  102673. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  102674. /**
  102675. * Instantiates a new ArcRotateCameraInputsManager.
  102676. * @param camera Defines the camera the inputs belong to
  102677. */
  102678. constructor(camera: ArcRotateCamera);
  102679. /**
  102680. * Add mouse wheel input support to the input manager.
  102681. * @returns the current input manager
  102682. */
  102683. addMouseWheel(): ArcRotateCameraInputsManager;
  102684. /**
  102685. * Add pointers input support to the input manager.
  102686. * @returns the current input manager
  102687. */
  102688. addPointers(): ArcRotateCameraInputsManager;
  102689. /**
  102690. * Add keyboard input support to the input manager.
  102691. * @returns the current input manager
  102692. */
  102693. addKeyboard(): ArcRotateCameraInputsManager;
  102694. }
  102695. }
  102696. declare module BABYLON {
  102697. /**
  102698. * This represents an orbital type of camera.
  102699. *
  102700. * 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.
  102701. * 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.
  102702. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  102703. */
  102704. export class ArcRotateCamera extends TargetCamera {
  102705. /**
  102706. * Defines the rotation angle of the camera along the longitudinal axis.
  102707. */
  102708. alpha: number;
  102709. /**
  102710. * Defines the rotation angle of the camera along the latitudinal axis.
  102711. */
  102712. beta: number;
  102713. /**
  102714. * Defines the radius of the camera from it s target point.
  102715. */
  102716. radius: number;
  102717. protected _target: Vector3;
  102718. protected _targetHost: Nullable<AbstractMesh>;
  102719. /**
  102720. * Defines the target point of the camera.
  102721. * The camera looks towards it form the radius distance.
  102722. */
  102723. target: Vector3;
  102724. /**
  102725. * Define the current local position of the camera in the scene
  102726. */
  102727. position: Vector3;
  102728. protected _upVector: Vector3;
  102729. protected _upToYMatrix: Matrix;
  102730. protected _YToUpMatrix: Matrix;
  102731. /**
  102732. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  102733. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  102734. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  102735. */
  102736. upVector: Vector3;
  102737. /**
  102738. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  102739. */
  102740. setMatUp(): void;
  102741. /**
  102742. * Current inertia value on the longitudinal axis.
  102743. * The bigger this number the longer it will take for the camera to stop.
  102744. */
  102745. inertialAlphaOffset: number;
  102746. /**
  102747. * Current inertia value on the latitudinal axis.
  102748. * The bigger this number the longer it will take for the camera to stop.
  102749. */
  102750. inertialBetaOffset: number;
  102751. /**
  102752. * Current inertia value on the radius axis.
  102753. * The bigger this number the longer it will take for the camera to stop.
  102754. */
  102755. inertialRadiusOffset: number;
  102756. /**
  102757. * Minimum allowed angle on the longitudinal axis.
  102758. * This can help limiting how the Camera is able to move in the scene.
  102759. */
  102760. lowerAlphaLimit: Nullable<number>;
  102761. /**
  102762. * Maximum allowed angle on the longitudinal axis.
  102763. * This can help limiting how the Camera is able to move in the scene.
  102764. */
  102765. upperAlphaLimit: Nullable<number>;
  102766. /**
  102767. * Minimum allowed angle on the latitudinal axis.
  102768. * This can help limiting how the Camera is able to move in the scene.
  102769. */
  102770. lowerBetaLimit: number;
  102771. /**
  102772. * Maximum allowed angle on the latitudinal axis.
  102773. * This can help limiting how the Camera is able to move in the scene.
  102774. */
  102775. upperBetaLimit: number;
  102776. /**
  102777. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  102778. * This can help limiting how the Camera is able to move in the scene.
  102779. */
  102780. lowerRadiusLimit: Nullable<number>;
  102781. /**
  102782. * Maximum allowed distance of the camera to the target (The camera can not get further).
  102783. * This can help limiting how the Camera is able to move in the scene.
  102784. */
  102785. upperRadiusLimit: Nullable<number>;
  102786. /**
  102787. * Defines the current inertia value used during panning of the camera along the X axis.
  102788. */
  102789. inertialPanningX: number;
  102790. /**
  102791. * Defines the current inertia value used during panning of the camera along the Y axis.
  102792. */
  102793. inertialPanningY: number;
  102794. /**
  102795. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  102796. * Basically if your fingers moves away from more than this distance you will be considered
  102797. * in pinch mode.
  102798. */
  102799. pinchToPanMaxDistance: number;
  102800. /**
  102801. * Defines the maximum distance the camera can pan.
  102802. * This could help keeping the cammera always in your scene.
  102803. */
  102804. panningDistanceLimit: Nullable<number>;
  102805. /**
  102806. * Defines the target of the camera before paning.
  102807. */
  102808. panningOriginTarget: Vector3;
  102809. /**
  102810. * Defines the value of the inertia used during panning.
  102811. * 0 would mean stop inertia and one would mean no decelleration at all.
  102812. */
  102813. panningInertia: number;
  102814. /**
  102815. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  102816. */
  102817. angularSensibilityX: number;
  102818. /**
  102819. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  102820. */
  102821. angularSensibilityY: number;
  102822. /**
  102823. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  102824. */
  102825. pinchPrecision: number;
  102826. /**
  102827. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  102828. * It will be used instead of pinchDeltaPrecision if different from 0.
  102829. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102830. */
  102831. pinchDeltaPercentage: number;
  102832. /**
  102833. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  102834. */
  102835. panningSensibility: number;
  102836. /**
  102837. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  102838. */
  102839. keysUp: number[];
  102840. /**
  102841. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  102842. */
  102843. keysDown: number[];
  102844. /**
  102845. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  102846. */
  102847. keysLeft: number[];
  102848. /**
  102849. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  102850. */
  102851. keysRight: number[];
  102852. /**
  102853. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  102854. */
  102855. wheelPrecision: number;
  102856. /**
  102857. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  102858. * It will be used instead of pinchDeltaPrecision if different from 0.
  102859. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102860. */
  102861. wheelDeltaPercentage: number;
  102862. /**
  102863. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  102864. */
  102865. zoomOnFactor: number;
  102866. /**
  102867. * Defines a screen offset for the camera position.
  102868. */
  102869. targetScreenOffset: Vector2;
  102870. /**
  102871. * Allows the camera to be completely reversed.
  102872. * If false the camera can not arrive upside down.
  102873. */
  102874. allowUpsideDown: boolean;
  102875. /**
  102876. * Define if double tap/click is used to restore the previously saved state of the camera.
  102877. */
  102878. useInputToRestoreState: boolean;
  102879. /** @hidden */
  102880. _viewMatrix: Matrix;
  102881. /** @hidden */
  102882. _useCtrlForPanning: boolean;
  102883. /** @hidden */
  102884. _panningMouseButton: number;
  102885. /**
  102886. * Defines the input associated to the camera.
  102887. */
  102888. inputs: ArcRotateCameraInputsManager;
  102889. /** @hidden */
  102890. _reset: () => void;
  102891. /**
  102892. * Defines the allowed panning axis.
  102893. */
  102894. panningAxis: Vector3;
  102895. protected _localDirection: Vector3;
  102896. protected _transformedDirection: Vector3;
  102897. private _bouncingBehavior;
  102898. /**
  102899. * Gets the bouncing behavior of the camera if it has been enabled.
  102900. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102901. */
  102902. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  102903. /**
  102904. * Defines if the bouncing behavior of the camera is enabled on the camera.
  102905. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102906. */
  102907. useBouncingBehavior: boolean;
  102908. private _framingBehavior;
  102909. /**
  102910. * Gets the framing behavior of the camera if it has been enabled.
  102911. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102912. */
  102913. readonly framingBehavior: Nullable<FramingBehavior>;
  102914. /**
  102915. * Defines if the framing behavior of the camera is enabled on the camera.
  102916. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102917. */
  102918. useFramingBehavior: boolean;
  102919. private _autoRotationBehavior;
  102920. /**
  102921. * Gets the auto rotation behavior of the camera if it has been enabled.
  102922. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102923. */
  102924. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  102925. /**
  102926. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  102927. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102928. */
  102929. useAutoRotationBehavior: boolean;
  102930. /**
  102931. * Observable triggered when the mesh target has been changed on the camera.
  102932. */
  102933. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  102934. /**
  102935. * Event raised when the camera is colliding with a mesh.
  102936. */
  102937. onCollide: (collidedMesh: AbstractMesh) => void;
  102938. /**
  102939. * Defines whether the camera should check collision with the objects oh the scene.
  102940. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  102941. */
  102942. checkCollisions: boolean;
  102943. /**
  102944. * Defines the collision radius of the camera.
  102945. * This simulates a sphere around the camera.
  102946. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  102947. */
  102948. collisionRadius: Vector3;
  102949. protected _collider: Collider;
  102950. protected _previousPosition: Vector3;
  102951. protected _collisionVelocity: Vector3;
  102952. protected _newPosition: Vector3;
  102953. protected _previousAlpha: number;
  102954. protected _previousBeta: number;
  102955. protected _previousRadius: number;
  102956. protected _collisionTriggered: boolean;
  102957. protected _targetBoundingCenter: Nullable<Vector3>;
  102958. private _computationVector;
  102959. /**
  102960. * Instantiates a new ArcRotateCamera in a given scene
  102961. * @param name Defines the name of the camera
  102962. * @param alpha Defines the camera rotation along the logitudinal axis
  102963. * @param beta Defines the camera rotation along the latitudinal axis
  102964. * @param radius Defines the camera distance from its target
  102965. * @param target Defines the camera target
  102966. * @param scene Defines the scene the camera belongs to
  102967. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  102968. */
  102969. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102970. /** @hidden */
  102971. _initCache(): void;
  102972. /** @hidden */
  102973. _updateCache(ignoreParentClass?: boolean): void;
  102974. protected _getTargetPosition(): Vector3;
  102975. private _storedAlpha;
  102976. private _storedBeta;
  102977. private _storedRadius;
  102978. private _storedTarget;
  102979. private _storedTargetScreenOffset;
  102980. /**
  102981. * Stores the current state of the camera (alpha, beta, radius and target)
  102982. * @returns the camera itself
  102983. */
  102984. storeState(): Camera;
  102985. /**
  102986. * @hidden
  102987. * Restored camera state. You must call storeState() first
  102988. */
  102989. _restoreStateValues(): boolean;
  102990. /** @hidden */
  102991. _isSynchronizedViewMatrix(): boolean;
  102992. /**
  102993. * Attached controls to the current camera.
  102994. * @param element Defines the element the controls should be listened from
  102995. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102996. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  102997. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  102998. */
  102999. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  103000. /**
  103001. * Detach the current controls from the camera.
  103002. * The camera will stop reacting to inputs.
  103003. * @param element Defines the element to stop listening the inputs from
  103004. */
  103005. detachControl(element: HTMLElement): void;
  103006. /** @hidden */
  103007. _checkInputs(): void;
  103008. protected _checkLimits(): void;
  103009. /**
  103010. * Rebuilds angles (alpha, beta) and radius from the give position and target
  103011. */
  103012. rebuildAnglesAndRadius(): void;
  103013. /**
  103014. * Use a position to define the current camera related information like aplha, beta and radius
  103015. * @param position Defines the position to set the camera at
  103016. */
  103017. setPosition(position: Vector3): void;
  103018. /**
  103019. * Defines the target the camera should look at.
  103020. * This will automatically adapt alpha beta and radius to fit within the new target.
  103021. * @param target Defines the new target as a Vector or a mesh
  103022. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  103023. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  103024. */
  103025. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  103026. /** @hidden */
  103027. _getViewMatrix(): Matrix;
  103028. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  103029. /**
  103030. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  103031. * @param meshes Defines the mesh to zoom on
  103032. * @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)
  103033. */
  103034. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  103035. /**
  103036. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  103037. * The target will be changed but the radius
  103038. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  103039. * @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)
  103040. */
  103041. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  103042. min: Vector3;
  103043. max: Vector3;
  103044. distance: number;
  103045. }, doNotUpdateMaxZ?: boolean): void;
  103046. /**
  103047. * @override
  103048. * Override Camera.createRigCamera
  103049. */
  103050. createRigCamera(name: string, cameraIndex: number): Camera;
  103051. /**
  103052. * @hidden
  103053. * @override
  103054. * Override Camera._updateRigCameras
  103055. */
  103056. _updateRigCameras(): void;
  103057. /**
  103058. * Destroy the camera and release the current resources hold by it.
  103059. */
  103060. dispose(): void;
  103061. /**
  103062. * Gets the current object class name.
  103063. * @return the class name
  103064. */
  103065. getClassName(): string;
  103066. }
  103067. }
  103068. declare module BABYLON {
  103069. /**
  103070. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  103071. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103072. */
  103073. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  103074. /**
  103075. * Gets the name of the behavior.
  103076. */
  103077. readonly name: string;
  103078. private _zoomStopsAnimation;
  103079. private _idleRotationSpeed;
  103080. private _idleRotationWaitTime;
  103081. private _idleRotationSpinupTime;
  103082. /**
  103083. * Sets the flag that indicates if user zooming should stop animation.
  103084. */
  103085. /**
  103086. * Gets the flag that indicates if user zooming should stop animation.
  103087. */
  103088. zoomStopsAnimation: boolean;
  103089. /**
  103090. * Sets the default speed at which the camera rotates around the model.
  103091. */
  103092. /**
  103093. * Gets the default speed at which the camera rotates around the model.
  103094. */
  103095. idleRotationSpeed: number;
  103096. /**
  103097. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  103098. */
  103099. /**
  103100. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  103101. */
  103102. idleRotationWaitTime: number;
  103103. /**
  103104. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103105. */
  103106. /**
  103107. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103108. */
  103109. idleRotationSpinupTime: number;
  103110. /**
  103111. * Gets a value indicating if the camera is currently rotating because of this behavior
  103112. */
  103113. readonly rotationInProgress: boolean;
  103114. private _onPrePointerObservableObserver;
  103115. private _onAfterCheckInputsObserver;
  103116. private _attachedCamera;
  103117. private _isPointerDown;
  103118. private _lastFrameTime;
  103119. private _lastInteractionTime;
  103120. private _cameraRotationSpeed;
  103121. /**
  103122. * Initializes the behavior.
  103123. */
  103124. init(): void;
  103125. /**
  103126. * Attaches the behavior to its arc rotate camera.
  103127. * @param camera Defines the camera to attach the behavior to
  103128. */
  103129. attach(camera: ArcRotateCamera): void;
  103130. /**
  103131. * Detaches the behavior from its current arc rotate camera.
  103132. */
  103133. detach(): void;
  103134. /**
  103135. * Returns true if user is scrolling.
  103136. * @return true if user is scrolling.
  103137. */
  103138. private _userIsZooming;
  103139. private _lastFrameRadius;
  103140. private _shouldAnimationStopForInteraction;
  103141. /**
  103142. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103143. */
  103144. private _applyUserInteraction;
  103145. private _userIsMoving;
  103146. }
  103147. }
  103148. declare module BABYLON {
  103149. /**
  103150. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  103151. */
  103152. export class AttachToBoxBehavior implements Behavior<Mesh> {
  103153. private ui;
  103154. /**
  103155. * The name of the behavior
  103156. */
  103157. name: string;
  103158. /**
  103159. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  103160. */
  103161. distanceAwayFromFace: number;
  103162. /**
  103163. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  103164. */
  103165. distanceAwayFromBottomOfFace: number;
  103166. private _faceVectors;
  103167. private _target;
  103168. private _scene;
  103169. private _onRenderObserver;
  103170. private _tmpMatrix;
  103171. private _tmpVector;
  103172. /**
  103173. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  103174. * @param ui The transform node that should be attched to the mesh
  103175. */
  103176. constructor(ui: TransformNode);
  103177. /**
  103178. * Initializes the behavior
  103179. */
  103180. init(): void;
  103181. private _closestFace;
  103182. private _zeroVector;
  103183. private _lookAtTmpMatrix;
  103184. private _lookAtToRef;
  103185. /**
  103186. * Attaches the AttachToBoxBehavior to the passed in mesh
  103187. * @param target The mesh that the specified node will be attached to
  103188. */
  103189. attach(target: Mesh): void;
  103190. /**
  103191. * Detaches the behavior from the mesh
  103192. */
  103193. detach(): void;
  103194. }
  103195. }
  103196. declare module BABYLON {
  103197. /**
  103198. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  103199. */
  103200. export class FadeInOutBehavior implements Behavior<Mesh> {
  103201. /**
  103202. * Time in milliseconds to delay before fading in (Default: 0)
  103203. */
  103204. delay: number;
  103205. /**
  103206. * Time in milliseconds for the mesh to fade in (Default: 300)
  103207. */
  103208. fadeInTime: number;
  103209. private _millisecondsPerFrame;
  103210. private _hovered;
  103211. private _hoverValue;
  103212. private _ownerNode;
  103213. /**
  103214. * Instatiates the FadeInOutBehavior
  103215. */
  103216. constructor();
  103217. /**
  103218. * The name of the behavior
  103219. */
  103220. readonly name: string;
  103221. /**
  103222. * Initializes the behavior
  103223. */
  103224. init(): void;
  103225. /**
  103226. * Attaches the fade behavior on the passed in mesh
  103227. * @param ownerNode The mesh that will be faded in/out once attached
  103228. */
  103229. attach(ownerNode: Mesh): void;
  103230. /**
  103231. * Detaches the behavior from the mesh
  103232. */
  103233. detach(): void;
  103234. /**
  103235. * Triggers the mesh to begin fading in or out
  103236. * @param value if the object should fade in or out (true to fade in)
  103237. */
  103238. fadeIn(value: boolean): void;
  103239. private _update;
  103240. private _setAllVisibility;
  103241. }
  103242. }
  103243. declare module BABYLON {
  103244. /**
  103245. * Class containing a set of static utilities functions for managing Pivots
  103246. * @hidden
  103247. */
  103248. export class PivotTools {
  103249. private static _PivotCached;
  103250. private static _OldPivotPoint;
  103251. private static _PivotTranslation;
  103252. private static _PivotTmpVector;
  103253. /** @hidden */
  103254. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  103255. /** @hidden */
  103256. static _RestorePivotPoint(mesh: AbstractMesh): void;
  103257. }
  103258. }
  103259. declare module BABYLON {
  103260. /**
  103261. * Class containing static functions to help procedurally build meshes
  103262. */
  103263. export class PlaneBuilder {
  103264. /**
  103265. * Creates a plane mesh
  103266. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  103267. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  103268. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  103269. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103270. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103272. * @param name defines the name of the mesh
  103273. * @param options defines the options used to create the mesh
  103274. * @param scene defines the hosting scene
  103275. * @returns the plane mesh
  103276. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  103277. */
  103278. static CreatePlane(name: string, options: {
  103279. size?: number;
  103280. width?: number;
  103281. height?: number;
  103282. sideOrientation?: number;
  103283. frontUVs?: Vector4;
  103284. backUVs?: Vector4;
  103285. updatable?: boolean;
  103286. sourcePlane?: Plane;
  103287. }, scene?: Nullable<Scene>): Mesh;
  103288. }
  103289. }
  103290. declare module BABYLON {
  103291. /**
  103292. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  103293. */
  103294. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  103295. private static _AnyMouseID;
  103296. /**
  103297. * Abstract mesh the behavior is set on
  103298. */
  103299. attachedNode: AbstractMesh;
  103300. private _dragPlane;
  103301. private _scene;
  103302. private _pointerObserver;
  103303. private _beforeRenderObserver;
  103304. private static _planeScene;
  103305. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  103306. /**
  103307. * 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)
  103308. */
  103309. maxDragAngle: number;
  103310. /**
  103311. * @hidden
  103312. */
  103313. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  103314. /**
  103315. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103316. */
  103317. currentDraggingPointerID: number;
  103318. /**
  103319. * The last position where the pointer hit the drag plane in world space
  103320. */
  103321. lastDragPosition: Vector3;
  103322. /**
  103323. * If the behavior is currently in a dragging state
  103324. */
  103325. dragging: boolean;
  103326. /**
  103327. * 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)
  103328. */
  103329. dragDeltaRatio: number;
  103330. /**
  103331. * If the drag plane orientation should be updated during the dragging (Default: true)
  103332. */
  103333. updateDragPlane: boolean;
  103334. private _debugMode;
  103335. private _moving;
  103336. /**
  103337. * Fires each time the attached mesh is dragged with the pointer
  103338. * * delta between last drag position and current drag position in world space
  103339. * * dragDistance along the drag axis
  103340. * * dragPlaneNormal normal of the current drag plane used during the drag
  103341. * * dragPlanePoint in world space where the drag intersects the drag plane
  103342. */
  103343. onDragObservable: Observable<{
  103344. delta: Vector3;
  103345. dragPlanePoint: Vector3;
  103346. dragPlaneNormal: Vector3;
  103347. dragDistance: number;
  103348. pointerId: number;
  103349. }>;
  103350. /**
  103351. * Fires each time a drag begins (eg. mouse down on mesh)
  103352. */
  103353. onDragStartObservable: Observable<{
  103354. dragPlanePoint: Vector3;
  103355. pointerId: number;
  103356. }>;
  103357. /**
  103358. * Fires each time a drag ends (eg. mouse release after drag)
  103359. */
  103360. onDragEndObservable: Observable<{
  103361. dragPlanePoint: Vector3;
  103362. pointerId: number;
  103363. }>;
  103364. /**
  103365. * If the attached mesh should be moved when dragged
  103366. */
  103367. moveAttached: boolean;
  103368. /**
  103369. * If the drag behavior will react to drag events (Default: true)
  103370. */
  103371. enabled: boolean;
  103372. /**
  103373. * If pointer events should start and release the drag (Default: true)
  103374. */
  103375. startAndReleaseDragOnPointerEvents: boolean;
  103376. /**
  103377. * If camera controls should be detached during the drag
  103378. */
  103379. detachCameraControls: boolean;
  103380. /**
  103381. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  103382. */
  103383. useObjectOrienationForDragging: boolean;
  103384. private _options;
  103385. /**
  103386. * Creates a pointer drag behavior that can be attached to a mesh
  103387. * @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)
  103388. */
  103389. constructor(options?: {
  103390. dragAxis?: Vector3;
  103391. dragPlaneNormal?: Vector3;
  103392. });
  103393. /**
  103394. * Predicate to determine if it is valid to move the object to a new position when it is moved
  103395. */
  103396. validateDrag: (targetPosition: Vector3) => boolean;
  103397. /**
  103398. * The name of the behavior
  103399. */
  103400. readonly name: string;
  103401. /**
  103402. * Initializes the behavior
  103403. */
  103404. init(): void;
  103405. private _tmpVector;
  103406. private _alternatePickedPoint;
  103407. private _worldDragAxis;
  103408. private _targetPosition;
  103409. private _attachedElement;
  103410. /**
  103411. * Attaches the drag behavior the passed in mesh
  103412. * @param ownerNode The mesh that will be dragged around once attached
  103413. * @param predicate Predicate to use for pick filtering
  103414. */
  103415. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  103416. /**
  103417. * Force relase the drag action by code.
  103418. */
  103419. releaseDrag(): void;
  103420. private _startDragRay;
  103421. private _lastPointerRay;
  103422. /**
  103423. * Simulates the start of a pointer drag event on the behavior
  103424. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  103425. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  103426. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  103427. */
  103428. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  103429. private _startDrag;
  103430. private _dragDelta;
  103431. private _moveDrag;
  103432. private _pickWithRayOnDragPlane;
  103433. private _pointA;
  103434. private _pointB;
  103435. private _pointC;
  103436. private _lineA;
  103437. private _lineB;
  103438. private _localAxis;
  103439. private _lookAt;
  103440. private _updateDragPlanePosition;
  103441. /**
  103442. * Detaches the behavior from the mesh
  103443. */
  103444. detach(): void;
  103445. }
  103446. }
  103447. declare module BABYLON {
  103448. /**
  103449. * A behavior that when attached to a mesh will allow the mesh to be scaled
  103450. */
  103451. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  103452. private _dragBehaviorA;
  103453. private _dragBehaviorB;
  103454. private _startDistance;
  103455. private _initialScale;
  103456. private _targetScale;
  103457. private _ownerNode;
  103458. private _sceneRenderObserver;
  103459. /**
  103460. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  103461. */
  103462. constructor();
  103463. /**
  103464. * The name of the behavior
  103465. */
  103466. readonly name: string;
  103467. /**
  103468. * Initializes the behavior
  103469. */
  103470. init(): void;
  103471. private _getCurrentDistance;
  103472. /**
  103473. * Attaches the scale behavior the passed in mesh
  103474. * @param ownerNode The mesh that will be scaled around once attached
  103475. */
  103476. attach(ownerNode: Mesh): void;
  103477. /**
  103478. * Detaches the behavior from the mesh
  103479. */
  103480. detach(): void;
  103481. }
  103482. }
  103483. declare module BABYLON {
  103484. /**
  103485. * 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
  103486. */
  103487. export class SixDofDragBehavior implements Behavior<Mesh> {
  103488. private static _virtualScene;
  103489. private _ownerNode;
  103490. private _sceneRenderObserver;
  103491. private _scene;
  103492. private _targetPosition;
  103493. private _virtualOriginMesh;
  103494. private _virtualDragMesh;
  103495. private _pointerObserver;
  103496. private _moving;
  103497. private _startingOrientation;
  103498. /**
  103499. * 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)
  103500. */
  103501. private zDragFactor;
  103502. /**
  103503. * If the object should rotate to face the drag origin
  103504. */
  103505. rotateDraggedObject: boolean;
  103506. /**
  103507. * If the behavior is currently in a dragging state
  103508. */
  103509. dragging: boolean;
  103510. /**
  103511. * 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)
  103512. */
  103513. dragDeltaRatio: number;
  103514. /**
  103515. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103516. */
  103517. currentDraggingPointerID: number;
  103518. /**
  103519. * If camera controls should be detached during the drag
  103520. */
  103521. detachCameraControls: boolean;
  103522. /**
  103523. * Fires each time a drag starts
  103524. */
  103525. onDragStartObservable: Observable<{}>;
  103526. /**
  103527. * Fires each time a drag ends (eg. mouse release after drag)
  103528. */
  103529. onDragEndObservable: Observable<{}>;
  103530. /**
  103531. * 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
  103532. */
  103533. constructor();
  103534. /**
  103535. * The name of the behavior
  103536. */
  103537. readonly name: string;
  103538. /**
  103539. * Initializes the behavior
  103540. */
  103541. init(): void;
  103542. /**
  103543. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  103544. */
  103545. private readonly _pointerCamera;
  103546. /**
  103547. * Attaches the scale behavior the passed in mesh
  103548. * @param ownerNode The mesh that will be scaled around once attached
  103549. */
  103550. attach(ownerNode: Mesh): void;
  103551. /**
  103552. * Detaches the behavior from the mesh
  103553. */
  103554. detach(): void;
  103555. }
  103556. }
  103557. declare module BABYLON {
  103558. /**
  103559. * Class used to apply inverse kinematics to bones
  103560. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  103561. */
  103562. export class BoneIKController {
  103563. private static _tmpVecs;
  103564. private static _tmpQuat;
  103565. private static _tmpMats;
  103566. /**
  103567. * Gets or sets the target mesh
  103568. */
  103569. targetMesh: AbstractMesh;
  103570. /** Gets or sets the mesh used as pole */
  103571. poleTargetMesh: AbstractMesh;
  103572. /**
  103573. * Gets or sets the bone used as pole
  103574. */
  103575. poleTargetBone: Nullable<Bone>;
  103576. /**
  103577. * Gets or sets the target position
  103578. */
  103579. targetPosition: Vector3;
  103580. /**
  103581. * Gets or sets the pole target position
  103582. */
  103583. poleTargetPosition: Vector3;
  103584. /**
  103585. * Gets or sets the pole target local offset
  103586. */
  103587. poleTargetLocalOffset: Vector3;
  103588. /**
  103589. * Gets or sets the pole angle
  103590. */
  103591. poleAngle: number;
  103592. /**
  103593. * Gets or sets the mesh associated with the controller
  103594. */
  103595. mesh: AbstractMesh;
  103596. /**
  103597. * 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)
  103598. */
  103599. slerpAmount: number;
  103600. private _bone1Quat;
  103601. private _bone1Mat;
  103602. private _bone2Ang;
  103603. private _bone1;
  103604. private _bone2;
  103605. private _bone1Length;
  103606. private _bone2Length;
  103607. private _maxAngle;
  103608. private _maxReach;
  103609. private _rightHandedSystem;
  103610. private _bendAxis;
  103611. private _slerping;
  103612. private _adjustRoll;
  103613. /**
  103614. * Gets or sets maximum allowed angle
  103615. */
  103616. maxAngle: number;
  103617. /**
  103618. * Creates a new BoneIKController
  103619. * @param mesh defines the mesh to control
  103620. * @param bone defines the bone to control
  103621. * @param options defines options to set up the controller
  103622. */
  103623. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  103624. targetMesh?: AbstractMesh;
  103625. poleTargetMesh?: AbstractMesh;
  103626. poleTargetBone?: Bone;
  103627. poleTargetLocalOffset?: Vector3;
  103628. poleAngle?: number;
  103629. bendAxis?: Vector3;
  103630. maxAngle?: number;
  103631. slerpAmount?: number;
  103632. });
  103633. private _setMaxAngle;
  103634. /**
  103635. * Force the controller to update the bones
  103636. */
  103637. update(): void;
  103638. }
  103639. }
  103640. declare module BABYLON {
  103641. /**
  103642. * Class used to make a bone look toward a point in space
  103643. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  103644. */
  103645. export class BoneLookController {
  103646. private static _tmpVecs;
  103647. private static _tmpQuat;
  103648. private static _tmpMats;
  103649. /**
  103650. * The target Vector3 that the bone will look at
  103651. */
  103652. target: Vector3;
  103653. /**
  103654. * The mesh that the bone is attached to
  103655. */
  103656. mesh: AbstractMesh;
  103657. /**
  103658. * The bone that will be looking to the target
  103659. */
  103660. bone: Bone;
  103661. /**
  103662. * The up axis of the coordinate system that is used when the bone is rotated
  103663. */
  103664. upAxis: Vector3;
  103665. /**
  103666. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  103667. */
  103668. upAxisSpace: Space;
  103669. /**
  103670. * Used to make an adjustment to the yaw of the bone
  103671. */
  103672. adjustYaw: number;
  103673. /**
  103674. * Used to make an adjustment to the pitch of the bone
  103675. */
  103676. adjustPitch: number;
  103677. /**
  103678. * Used to make an adjustment to the roll of the bone
  103679. */
  103680. adjustRoll: number;
  103681. /**
  103682. * 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)
  103683. */
  103684. slerpAmount: number;
  103685. private _minYaw;
  103686. private _maxYaw;
  103687. private _minPitch;
  103688. private _maxPitch;
  103689. private _minYawSin;
  103690. private _minYawCos;
  103691. private _maxYawSin;
  103692. private _maxYawCos;
  103693. private _midYawConstraint;
  103694. private _minPitchTan;
  103695. private _maxPitchTan;
  103696. private _boneQuat;
  103697. private _slerping;
  103698. private _transformYawPitch;
  103699. private _transformYawPitchInv;
  103700. private _firstFrameSkipped;
  103701. private _yawRange;
  103702. private _fowardAxis;
  103703. /**
  103704. * Gets or sets the minimum yaw angle that the bone can look to
  103705. */
  103706. minYaw: number;
  103707. /**
  103708. * Gets or sets the maximum yaw angle that the bone can look to
  103709. */
  103710. maxYaw: number;
  103711. /**
  103712. * Gets or sets the minimum pitch angle that the bone can look to
  103713. */
  103714. minPitch: number;
  103715. /**
  103716. * Gets or sets the maximum pitch angle that the bone can look to
  103717. */
  103718. maxPitch: number;
  103719. /**
  103720. * Create a BoneLookController
  103721. * @param mesh the mesh that the bone belongs to
  103722. * @param bone the bone that will be looking to the target
  103723. * @param target the target Vector3 to look at
  103724. * @param options optional settings:
  103725. * * maxYaw: the maximum angle the bone will yaw to
  103726. * * minYaw: the minimum angle the bone will yaw to
  103727. * * maxPitch: the maximum angle the bone will pitch to
  103728. * * minPitch: the minimum angle the bone will yaw to
  103729. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  103730. * * upAxis: the up axis of the coordinate system
  103731. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  103732. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  103733. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  103734. * * adjustYaw: used to make an adjustment to the yaw of the bone
  103735. * * adjustPitch: used to make an adjustment to the pitch of the bone
  103736. * * adjustRoll: used to make an adjustment to the roll of the bone
  103737. **/
  103738. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  103739. maxYaw?: number;
  103740. minYaw?: number;
  103741. maxPitch?: number;
  103742. minPitch?: number;
  103743. slerpAmount?: number;
  103744. upAxis?: Vector3;
  103745. upAxisSpace?: Space;
  103746. yawAxis?: Vector3;
  103747. pitchAxis?: Vector3;
  103748. adjustYaw?: number;
  103749. adjustPitch?: number;
  103750. adjustRoll?: number;
  103751. });
  103752. /**
  103753. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  103754. */
  103755. update(): void;
  103756. private _getAngleDiff;
  103757. private _getAngleBetween;
  103758. private _isAngleBetween;
  103759. }
  103760. }
  103761. declare module BABYLON {
  103762. /**
  103763. * Manage the gamepad inputs to control an arc rotate camera.
  103764. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103765. */
  103766. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  103767. /**
  103768. * Defines the camera the input is attached to.
  103769. */
  103770. camera: ArcRotateCamera;
  103771. /**
  103772. * Defines the gamepad the input is gathering event from.
  103773. */
  103774. gamepad: Nullable<Gamepad>;
  103775. /**
  103776. * Defines the gamepad rotation sensiblity.
  103777. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103778. */
  103779. gamepadRotationSensibility: number;
  103780. /**
  103781. * Defines the gamepad move sensiblity.
  103782. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103783. */
  103784. gamepadMoveSensibility: number;
  103785. private _onGamepadConnectedObserver;
  103786. private _onGamepadDisconnectedObserver;
  103787. /**
  103788. * Attach the input controls to a specific dom element to get the input from.
  103789. * @param element Defines the element the controls should be listened from
  103790. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103791. */
  103792. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103793. /**
  103794. * Detach the current controls from the specified dom element.
  103795. * @param element Defines the element to stop listening the inputs from
  103796. */
  103797. detachControl(element: Nullable<HTMLElement>): void;
  103798. /**
  103799. * Update the current camera state depending on the inputs that have been used this frame.
  103800. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103801. */
  103802. checkInputs(): void;
  103803. /**
  103804. * Gets the class name of the current intput.
  103805. * @returns the class name
  103806. */
  103807. getClassName(): string;
  103808. /**
  103809. * Get the friendly name associated with the input class.
  103810. * @returns the input friendly name
  103811. */
  103812. getSimpleName(): string;
  103813. }
  103814. }
  103815. declare module BABYLON {
  103816. interface ArcRotateCameraInputsManager {
  103817. /**
  103818. * Add orientation input support to the input manager.
  103819. * @returns the current input manager
  103820. */
  103821. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  103822. }
  103823. /**
  103824. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  103825. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103826. */
  103827. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  103828. /**
  103829. * Defines the camera the input is attached to.
  103830. */
  103831. camera: ArcRotateCamera;
  103832. /**
  103833. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  103834. */
  103835. alphaCorrection: number;
  103836. /**
  103837. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  103838. */
  103839. gammaCorrection: number;
  103840. private _alpha;
  103841. private _gamma;
  103842. private _dirty;
  103843. private _deviceOrientationHandler;
  103844. /**
  103845. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  103846. */
  103847. constructor();
  103848. /**
  103849. * Attach the input controls to a specific dom element to get the input from.
  103850. * @param element Defines the element the controls should be listened from
  103851. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103852. */
  103853. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103854. /** @hidden */
  103855. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  103856. /**
  103857. * Update the current camera state depending on the inputs that have been used this frame.
  103858. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103859. */
  103860. checkInputs(): void;
  103861. /**
  103862. * Detach the current controls from the specified dom element.
  103863. * @param element Defines the element to stop listening the inputs from
  103864. */
  103865. detachControl(element: Nullable<HTMLElement>): void;
  103866. /**
  103867. * Gets the class name of the current intput.
  103868. * @returns the class name
  103869. */
  103870. getClassName(): string;
  103871. /**
  103872. * Get the friendly name associated with the input class.
  103873. * @returns the input friendly name
  103874. */
  103875. getSimpleName(): string;
  103876. }
  103877. }
  103878. declare module BABYLON {
  103879. /**
  103880. * Listen to mouse events to control the camera.
  103881. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103882. */
  103883. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  103884. /**
  103885. * Defines the camera the input is attached to.
  103886. */
  103887. camera: FlyCamera;
  103888. /**
  103889. * Defines if touch is enabled. (Default is true.)
  103890. */
  103891. touchEnabled: boolean;
  103892. /**
  103893. * Defines the buttons associated with the input to handle camera rotation.
  103894. */
  103895. buttons: number[];
  103896. /**
  103897. * Assign buttons for Yaw control.
  103898. */
  103899. buttonsYaw: number[];
  103900. /**
  103901. * Assign buttons for Pitch control.
  103902. */
  103903. buttonsPitch: number[];
  103904. /**
  103905. * Assign buttons for Roll control.
  103906. */
  103907. buttonsRoll: number[];
  103908. /**
  103909. * Detect if any button is being pressed while mouse is moved.
  103910. * -1 = Mouse locked.
  103911. * 0 = Left button.
  103912. * 1 = Middle Button.
  103913. * 2 = Right Button.
  103914. */
  103915. activeButton: number;
  103916. /**
  103917. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  103918. * Higher values reduce its sensitivity.
  103919. */
  103920. angularSensibility: number;
  103921. private _mousemoveCallback;
  103922. private _observer;
  103923. private _rollObserver;
  103924. private previousPosition;
  103925. private noPreventDefault;
  103926. private element;
  103927. /**
  103928. * Listen to mouse events to control the camera.
  103929. * @param touchEnabled Define if touch is enabled. (Default is true.)
  103930. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103931. */
  103932. constructor(touchEnabled?: boolean);
  103933. /**
  103934. * Attach the mouse control to the HTML DOM element.
  103935. * @param element Defines the element that listens to the input events.
  103936. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  103937. */
  103938. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103939. /**
  103940. * Detach the current controls from the specified dom element.
  103941. * @param element Defines the element to stop listening the inputs from
  103942. */
  103943. detachControl(element: Nullable<HTMLElement>): void;
  103944. /**
  103945. * Gets the class name of the current input.
  103946. * @returns the class name.
  103947. */
  103948. getClassName(): string;
  103949. /**
  103950. * Get the friendly name associated with the input class.
  103951. * @returns the input's friendly name.
  103952. */
  103953. getSimpleName(): string;
  103954. private _pointerInput;
  103955. private _onMouseMove;
  103956. /**
  103957. * Rotate camera by mouse offset.
  103958. */
  103959. private rotateCamera;
  103960. }
  103961. }
  103962. declare module BABYLON {
  103963. /**
  103964. * Default Inputs manager for the FlyCamera.
  103965. * It groups all the default supported inputs for ease of use.
  103966. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103967. */
  103968. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  103969. /**
  103970. * Instantiates a new FlyCameraInputsManager.
  103971. * @param camera Defines the camera the inputs belong to.
  103972. */
  103973. constructor(camera: FlyCamera);
  103974. /**
  103975. * Add keyboard input support to the input manager.
  103976. * @returns the new FlyCameraKeyboardMoveInput().
  103977. */
  103978. addKeyboard(): FlyCameraInputsManager;
  103979. /**
  103980. * Add mouse input support to the input manager.
  103981. * @param touchEnabled Enable touch screen support.
  103982. * @returns the new FlyCameraMouseInput().
  103983. */
  103984. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  103985. }
  103986. }
  103987. declare module BABYLON {
  103988. /**
  103989. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103990. * such as in a 3D Space Shooter or a Flight Simulator.
  103991. */
  103992. export class FlyCamera extends TargetCamera {
  103993. /**
  103994. * Define the collision ellipsoid of the camera.
  103995. * This is helpful for simulating a camera body, like a player's body.
  103996. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103997. */
  103998. ellipsoid: Vector3;
  103999. /**
  104000. * Define an offset for the position of the ellipsoid around the camera.
  104001. * This can be helpful if the camera is attached away from the player's body center,
  104002. * such as at its head.
  104003. */
  104004. ellipsoidOffset: Vector3;
  104005. /**
  104006. * Enable or disable collisions of the camera with the rest of the scene objects.
  104007. */
  104008. checkCollisions: boolean;
  104009. /**
  104010. * Enable or disable gravity on the camera.
  104011. */
  104012. applyGravity: boolean;
  104013. /**
  104014. * Define the current direction the camera is moving to.
  104015. */
  104016. cameraDirection: Vector3;
  104017. /**
  104018. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  104019. * This overrides and empties cameraRotation.
  104020. */
  104021. rotationQuaternion: Quaternion;
  104022. /**
  104023. * Track Roll to maintain the wanted Rolling when looking around.
  104024. */
  104025. _trackRoll: number;
  104026. /**
  104027. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  104028. */
  104029. rollCorrect: number;
  104030. /**
  104031. * Mimic a banked turn, Rolling the camera when Yawing.
  104032. * It's recommended to use rollCorrect = 10 for faster banking correction.
  104033. */
  104034. bankedTurn: boolean;
  104035. /**
  104036. * Limit in radians for how much Roll banking will add. (Default: 90°)
  104037. */
  104038. bankedTurnLimit: number;
  104039. /**
  104040. * Value of 0 disables the banked Roll.
  104041. * Value of 1 is equal to the Yaw angle in radians.
  104042. */
  104043. bankedTurnMultiplier: number;
  104044. /**
  104045. * The inputs manager loads all the input sources, such as keyboard and mouse.
  104046. */
  104047. inputs: FlyCameraInputsManager;
  104048. /**
  104049. * Gets the input sensibility for mouse input.
  104050. * Higher values reduce sensitivity.
  104051. */
  104052. /**
  104053. * Sets the input sensibility for a mouse input.
  104054. * Higher values reduce sensitivity.
  104055. */
  104056. angularSensibility: number;
  104057. /**
  104058. * Get the keys for camera movement forward.
  104059. */
  104060. /**
  104061. * Set the keys for camera movement forward.
  104062. */
  104063. keysForward: number[];
  104064. /**
  104065. * Get the keys for camera movement backward.
  104066. */
  104067. keysBackward: number[];
  104068. /**
  104069. * Get the keys for camera movement up.
  104070. */
  104071. /**
  104072. * Set the keys for camera movement up.
  104073. */
  104074. keysUp: number[];
  104075. /**
  104076. * Get the keys for camera movement down.
  104077. */
  104078. /**
  104079. * Set the keys for camera movement down.
  104080. */
  104081. keysDown: number[];
  104082. /**
  104083. * Get the keys for camera movement left.
  104084. */
  104085. /**
  104086. * Set the keys for camera movement left.
  104087. */
  104088. keysLeft: number[];
  104089. /**
  104090. * Set the keys for camera movement right.
  104091. */
  104092. /**
  104093. * Set the keys for camera movement right.
  104094. */
  104095. keysRight: number[];
  104096. /**
  104097. * Event raised when the camera collides with a mesh in the scene.
  104098. */
  104099. onCollide: (collidedMesh: AbstractMesh) => void;
  104100. private _collider;
  104101. private _needMoveForGravity;
  104102. private _oldPosition;
  104103. private _diffPosition;
  104104. private _newPosition;
  104105. /** @hidden */
  104106. _localDirection: Vector3;
  104107. /** @hidden */
  104108. _transformedDirection: Vector3;
  104109. /**
  104110. * Instantiates a FlyCamera.
  104111. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104112. * such as in a 3D Space Shooter or a Flight Simulator.
  104113. * @param name Define the name of the camera in the scene.
  104114. * @param position Define the starting position of the camera in the scene.
  104115. * @param scene Define the scene the camera belongs to.
  104116. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  104117. */
  104118. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104119. /**
  104120. * Attach a control to the HTML DOM element.
  104121. * @param element Defines the element that listens to the input events.
  104122. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  104123. */
  104124. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104125. /**
  104126. * Detach a control from the HTML DOM element.
  104127. * The camera will stop reacting to that input.
  104128. * @param element Defines the element that listens to the input events.
  104129. */
  104130. detachControl(element: HTMLElement): void;
  104131. private _collisionMask;
  104132. /**
  104133. * Get the mask that the camera ignores in collision events.
  104134. */
  104135. /**
  104136. * Set the mask that the camera ignores in collision events.
  104137. */
  104138. collisionMask: number;
  104139. /** @hidden */
  104140. _collideWithWorld(displacement: Vector3): void;
  104141. /** @hidden */
  104142. private _onCollisionPositionChange;
  104143. /** @hidden */
  104144. _checkInputs(): void;
  104145. /** @hidden */
  104146. _decideIfNeedsToMove(): boolean;
  104147. /** @hidden */
  104148. _updatePosition(): void;
  104149. /**
  104150. * Restore the Roll to its target value at the rate specified.
  104151. * @param rate - Higher means slower restoring.
  104152. * @hidden
  104153. */
  104154. restoreRoll(rate: number): void;
  104155. /**
  104156. * Destroy the camera and release the current resources held by it.
  104157. */
  104158. dispose(): void;
  104159. /**
  104160. * Get the current object class name.
  104161. * @returns the class name.
  104162. */
  104163. getClassName(): string;
  104164. }
  104165. }
  104166. declare module BABYLON {
  104167. /**
  104168. * Listen to keyboard events to control the camera.
  104169. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104170. */
  104171. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  104172. /**
  104173. * Defines the camera the input is attached to.
  104174. */
  104175. camera: FlyCamera;
  104176. /**
  104177. * The list of keyboard keys used to control the forward move of the camera.
  104178. */
  104179. keysForward: number[];
  104180. /**
  104181. * The list of keyboard keys used to control the backward move of the camera.
  104182. */
  104183. keysBackward: number[];
  104184. /**
  104185. * The list of keyboard keys used to control the forward move of the camera.
  104186. */
  104187. keysUp: number[];
  104188. /**
  104189. * The list of keyboard keys used to control the backward move of the camera.
  104190. */
  104191. keysDown: number[];
  104192. /**
  104193. * The list of keyboard keys used to control the right strafe move of the camera.
  104194. */
  104195. keysRight: number[];
  104196. /**
  104197. * The list of keyboard keys used to control the left strafe move of the camera.
  104198. */
  104199. keysLeft: number[];
  104200. private _keys;
  104201. private _onCanvasBlurObserver;
  104202. private _onKeyboardObserver;
  104203. private _engine;
  104204. private _scene;
  104205. /**
  104206. * Attach the input controls to a specific dom element to get the input from.
  104207. * @param element Defines the element the controls should be listened from
  104208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104209. */
  104210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104211. /**
  104212. * Detach the current controls from the specified dom element.
  104213. * @param element Defines the element to stop listening the inputs from
  104214. */
  104215. detachControl(element: Nullable<HTMLElement>): void;
  104216. /**
  104217. * Gets the class name of the current intput.
  104218. * @returns the class name
  104219. */
  104220. getClassName(): string;
  104221. /** @hidden */
  104222. _onLostFocus(e: FocusEvent): void;
  104223. /**
  104224. * Get the friendly name associated with the input class.
  104225. * @returns the input friendly name
  104226. */
  104227. getSimpleName(): string;
  104228. /**
  104229. * Update the current camera state depending on the inputs that have been used this frame.
  104230. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104231. */
  104232. checkInputs(): void;
  104233. }
  104234. }
  104235. declare module BABYLON {
  104236. /**
  104237. * Manage the mouse wheel inputs to control a follow camera.
  104238. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104239. */
  104240. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  104241. /**
  104242. * Defines the camera the input is attached to.
  104243. */
  104244. camera: FollowCamera;
  104245. /**
  104246. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  104247. */
  104248. axisControlRadius: boolean;
  104249. /**
  104250. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  104251. */
  104252. axisControlHeight: boolean;
  104253. /**
  104254. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  104255. */
  104256. axisControlRotation: boolean;
  104257. /**
  104258. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  104259. * relation to mouseWheel events.
  104260. */
  104261. wheelPrecision: number;
  104262. /**
  104263. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104264. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104265. */
  104266. wheelDeltaPercentage: number;
  104267. private _wheel;
  104268. private _observer;
  104269. /**
  104270. * Attach the input controls to a specific dom element to get the input from.
  104271. * @param element Defines the element the controls should be listened from
  104272. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104273. */
  104274. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104275. /**
  104276. * Detach the current controls from the specified dom element.
  104277. * @param element Defines the element to stop listening the inputs from
  104278. */
  104279. detachControl(element: Nullable<HTMLElement>): void;
  104280. /**
  104281. * Gets the class name of the current intput.
  104282. * @returns the class name
  104283. */
  104284. getClassName(): string;
  104285. /**
  104286. * Get the friendly name associated with the input class.
  104287. * @returns the input friendly name
  104288. */
  104289. getSimpleName(): string;
  104290. }
  104291. }
  104292. declare module BABYLON {
  104293. /**
  104294. * Manage the pointers inputs to control an follow camera.
  104295. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104296. */
  104297. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  104298. /**
  104299. * Defines the camera the input is attached to.
  104300. */
  104301. camera: FollowCamera;
  104302. /**
  104303. * Gets the class name of the current input.
  104304. * @returns the class name
  104305. */
  104306. getClassName(): string;
  104307. /**
  104308. * Defines the pointer angular sensibility along the X axis or how fast is
  104309. * the camera rotating.
  104310. * A negative number will reverse the axis direction.
  104311. */
  104312. angularSensibilityX: number;
  104313. /**
  104314. * Defines the pointer angular sensibility along the Y axis or how fast is
  104315. * the camera rotating.
  104316. * A negative number will reverse the axis direction.
  104317. */
  104318. angularSensibilityY: number;
  104319. /**
  104320. * Defines the pointer pinch precision or how fast is the camera zooming.
  104321. * A negative number will reverse the axis direction.
  104322. */
  104323. pinchPrecision: number;
  104324. /**
  104325. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104326. * from 0.
  104327. * It defines the percentage of current camera.radius to use as delta when
  104328. * pinch zoom is used.
  104329. */
  104330. pinchDeltaPercentage: number;
  104331. /**
  104332. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  104333. */
  104334. axisXControlRadius: boolean;
  104335. /**
  104336. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  104337. */
  104338. axisXControlHeight: boolean;
  104339. /**
  104340. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  104341. */
  104342. axisXControlRotation: boolean;
  104343. /**
  104344. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  104345. */
  104346. axisYControlRadius: boolean;
  104347. /**
  104348. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  104349. */
  104350. axisYControlHeight: boolean;
  104351. /**
  104352. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  104353. */
  104354. axisYControlRotation: boolean;
  104355. /**
  104356. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  104357. */
  104358. axisPinchControlRadius: boolean;
  104359. /**
  104360. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  104361. */
  104362. axisPinchControlHeight: boolean;
  104363. /**
  104364. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  104365. */
  104366. axisPinchControlRotation: boolean;
  104367. /**
  104368. * Log error messages if basic misconfiguration has occurred.
  104369. */
  104370. warningEnable: boolean;
  104371. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104372. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104373. private _warningCounter;
  104374. private _warning;
  104375. }
  104376. }
  104377. declare module BABYLON {
  104378. /**
  104379. * Default Inputs manager for the FollowCamera.
  104380. * It groups all the default supported inputs for ease of use.
  104381. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104382. */
  104383. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  104384. /**
  104385. * Instantiates a new FollowCameraInputsManager.
  104386. * @param camera Defines the camera the inputs belong to
  104387. */
  104388. constructor(camera: FollowCamera);
  104389. /**
  104390. * Add keyboard input support to the input manager.
  104391. * @returns the current input manager
  104392. */
  104393. addKeyboard(): FollowCameraInputsManager;
  104394. /**
  104395. * Add mouse wheel input support to the input manager.
  104396. * @returns the current input manager
  104397. */
  104398. addMouseWheel(): FollowCameraInputsManager;
  104399. /**
  104400. * Add pointers input support to the input manager.
  104401. * @returns the current input manager
  104402. */
  104403. addPointers(): FollowCameraInputsManager;
  104404. /**
  104405. * Add orientation input support to the input manager.
  104406. * @returns the current input manager
  104407. */
  104408. addVRDeviceOrientation(): FollowCameraInputsManager;
  104409. }
  104410. }
  104411. declare module BABYLON {
  104412. /**
  104413. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  104414. * an arc rotate version arcFollowCamera are available.
  104415. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104416. */
  104417. export class FollowCamera extends TargetCamera {
  104418. /**
  104419. * Distance the follow camera should follow an object at
  104420. */
  104421. radius: number;
  104422. /**
  104423. * Minimum allowed distance of the camera to the axis of rotation
  104424. * (The camera can not get closer).
  104425. * This can help limiting how the Camera is able to move in the scene.
  104426. */
  104427. lowerRadiusLimit: Nullable<number>;
  104428. /**
  104429. * Maximum allowed distance of the camera to the axis of rotation
  104430. * (The camera can not get further).
  104431. * This can help limiting how the Camera is able to move in the scene.
  104432. */
  104433. upperRadiusLimit: Nullable<number>;
  104434. /**
  104435. * Define a rotation offset between the camera and the object it follows
  104436. */
  104437. rotationOffset: number;
  104438. /**
  104439. * Minimum allowed angle to camera position relative to target object.
  104440. * This can help limiting how the Camera is able to move in the scene.
  104441. */
  104442. lowerRotationOffsetLimit: Nullable<number>;
  104443. /**
  104444. * Maximum allowed angle to camera position relative to target object.
  104445. * This can help limiting how the Camera is able to move in the scene.
  104446. */
  104447. upperRotationOffsetLimit: Nullable<number>;
  104448. /**
  104449. * Define a height offset between the camera and the object it follows.
  104450. * It can help following an object from the top (like a car chaing a plane)
  104451. */
  104452. heightOffset: number;
  104453. /**
  104454. * Minimum allowed height of camera position relative to target object.
  104455. * This can help limiting how the Camera is able to move in the scene.
  104456. */
  104457. lowerHeightOffsetLimit: Nullable<number>;
  104458. /**
  104459. * Maximum allowed height of camera position relative to target object.
  104460. * This can help limiting how the Camera is able to move in the scene.
  104461. */
  104462. upperHeightOffsetLimit: Nullable<number>;
  104463. /**
  104464. * Define how fast the camera can accelerate to follow it s target.
  104465. */
  104466. cameraAcceleration: number;
  104467. /**
  104468. * Define the speed limit of the camera following an object.
  104469. */
  104470. maxCameraSpeed: number;
  104471. /**
  104472. * Define the target of the camera.
  104473. */
  104474. lockedTarget: Nullable<AbstractMesh>;
  104475. /**
  104476. * Defines the input associated with the camera.
  104477. */
  104478. inputs: FollowCameraInputsManager;
  104479. /**
  104480. * Instantiates the follow camera.
  104481. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104482. * @param name Define the name of the camera in the scene
  104483. * @param position Define the position of the camera
  104484. * @param scene Define the scene the camera belong to
  104485. * @param lockedTarget Define the target of the camera
  104486. */
  104487. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  104488. private _follow;
  104489. /**
  104490. * Attached controls to the current camera.
  104491. * @param element Defines the element the controls should be listened from
  104492. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104493. */
  104494. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104495. /**
  104496. * Detach the current controls from the camera.
  104497. * The camera will stop reacting to inputs.
  104498. * @param element Defines the element to stop listening the inputs from
  104499. */
  104500. detachControl(element: HTMLElement): void;
  104501. /** @hidden */
  104502. _checkInputs(): void;
  104503. private _checkLimits;
  104504. /**
  104505. * Gets the camera class name.
  104506. * @returns the class name
  104507. */
  104508. getClassName(): string;
  104509. }
  104510. /**
  104511. * Arc Rotate version of the follow camera.
  104512. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  104513. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104514. */
  104515. export class ArcFollowCamera extends TargetCamera {
  104516. /** The longitudinal angle of the camera */
  104517. alpha: number;
  104518. /** The latitudinal angle of the camera */
  104519. beta: number;
  104520. /** The radius of the camera from its target */
  104521. radius: number;
  104522. /** Define the camera target (the messh it should follow) */
  104523. target: Nullable<AbstractMesh>;
  104524. private _cartesianCoordinates;
  104525. /**
  104526. * Instantiates a new ArcFollowCamera
  104527. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104528. * @param name Define the name of the camera
  104529. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  104530. * @param beta Define the rotation angle of the camera around the elevation axis
  104531. * @param radius Define the radius of the camera from its target point
  104532. * @param target Define the target of the camera
  104533. * @param scene Define the scene the camera belongs to
  104534. */
  104535. constructor(name: string,
  104536. /** The longitudinal angle of the camera */
  104537. alpha: number,
  104538. /** The latitudinal angle of the camera */
  104539. beta: number,
  104540. /** The radius of the camera from its target */
  104541. radius: number,
  104542. /** Define the camera target (the messh it should follow) */
  104543. target: Nullable<AbstractMesh>, scene: Scene);
  104544. private _follow;
  104545. /** @hidden */
  104546. _checkInputs(): void;
  104547. /**
  104548. * Returns the class name of the object.
  104549. * It is mostly used internally for serialization purposes.
  104550. */
  104551. getClassName(): string;
  104552. }
  104553. }
  104554. declare module BABYLON {
  104555. /**
  104556. * Manage the keyboard inputs to control the movement of a follow camera.
  104557. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104558. */
  104559. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  104560. /**
  104561. * Defines the camera the input is attached to.
  104562. */
  104563. camera: FollowCamera;
  104564. /**
  104565. * Defines the list of key codes associated with the up action (increase heightOffset)
  104566. */
  104567. keysHeightOffsetIncr: number[];
  104568. /**
  104569. * Defines the list of key codes associated with the down action (decrease heightOffset)
  104570. */
  104571. keysHeightOffsetDecr: number[];
  104572. /**
  104573. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  104574. */
  104575. keysHeightOffsetModifierAlt: boolean;
  104576. /**
  104577. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  104578. */
  104579. keysHeightOffsetModifierCtrl: boolean;
  104580. /**
  104581. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  104582. */
  104583. keysHeightOffsetModifierShift: boolean;
  104584. /**
  104585. * Defines the list of key codes associated with the left action (increase rotationOffset)
  104586. */
  104587. keysRotationOffsetIncr: number[];
  104588. /**
  104589. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  104590. */
  104591. keysRotationOffsetDecr: number[];
  104592. /**
  104593. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  104594. */
  104595. keysRotationOffsetModifierAlt: boolean;
  104596. /**
  104597. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  104598. */
  104599. keysRotationOffsetModifierCtrl: boolean;
  104600. /**
  104601. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  104602. */
  104603. keysRotationOffsetModifierShift: boolean;
  104604. /**
  104605. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  104606. */
  104607. keysRadiusIncr: number[];
  104608. /**
  104609. * Defines the list of key codes associated with the zoom-out action (increase radius)
  104610. */
  104611. keysRadiusDecr: number[];
  104612. /**
  104613. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  104614. */
  104615. keysRadiusModifierAlt: boolean;
  104616. /**
  104617. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  104618. */
  104619. keysRadiusModifierCtrl: boolean;
  104620. /**
  104621. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  104622. */
  104623. keysRadiusModifierShift: boolean;
  104624. /**
  104625. * Defines the rate of change of heightOffset.
  104626. */
  104627. heightSensibility: number;
  104628. /**
  104629. * Defines the rate of change of rotationOffset.
  104630. */
  104631. rotationSensibility: number;
  104632. /**
  104633. * Defines the rate of change of radius.
  104634. */
  104635. radiusSensibility: number;
  104636. private _keys;
  104637. private _ctrlPressed;
  104638. private _altPressed;
  104639. private _shiftPressed;
  104640. private _onCanvasBlurObserver;
  104641. private _onKeyboardObserver;
  104642. private _engine;
  104643. private _scene;
  104644. /**
  104645. * Attach the input controls to a specific dom element to get the input from.
  104646. * @param element Defines the element the controls should be listened from
  104647. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104648. */
  104649. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104650. /**
  104651. * Detach the current controls from the specified dom element.
  104652. * @param element Defines the element to stop listening the inputs from
  104653. */
  104654. detachControl(element: Nullable<HTMLElement>): void;
  104655. /**
  104656. * Update the current camera state depending on the inputs that have been used this frame.
  104657. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104658. */
  104659. checkInputs(): void;
  104660. /**
  104661. * Gets the class name of the current input.
  104662. * @returns the class name
  104663. */
  104664. getClassName(): string;
  104665. /**
  104666. * Get the friendly name associated with the input class.
  104667. * @returns the input friendly name
  104668. */
  104669. getSimpleName(): string;
  104670. /**
  104671. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104672. * allow modification of the heightOffset value.
  104673. */
  104674. private _modifierHeightOffset;
  104675. /**
  104676. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104677. * allow modification of the rotationOffset value.
  104678. */
  104679. private _modifierRotationOffset;
  104680. /**
  104681. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104682. * allow modification of the radius value.
  104683. */
  104684. private _modifierRadius;
  104685. }
  104686. }
  104687. declare module BABYLON {
  104688. interface FreeCameraInputsManager {
  104689. /**
  104690. * @hidden
  104691. */
  104692. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  104693. /**
  104694. * Add orientation input support to the input manager.
  104695. * @returns the current input manager
  104696. */
  104697. addDeviceOrientation(): FreeCameraInputsManager;
  104698. }
  104699. /**
  104700. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  104701. * Screen rotation is taken into account.
  104702. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104703. */
  104704. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  104705. private _camera;
  104706. private _screenOrientationAngle;
  104707. private _constantTranform;
  104708. private _screenQuaternion;
  104709. private _alpha;
  104710. private _beta;
  104711. private _gamma;
  104712. /**
  104713. * Can be used to detect if a device orientation sensor is availible on a device
  104714. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  104715. * @returns a promise that will resolve on orientation change
  104716. */
  104717. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  104718. /**
  104719. * @hidden
  104720. */
  104721. _onDeviceOrientationChangedObservable: Observable<void>;
  104722. /**
  104723. * Instantiates a new input
  104724. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104725. */
  104726. constructor();
  104727. /**
  104728. * Define the camera controlled by the input.
  104729. */
  104730. camera: FreeCamera;
  104731. /**
  104732. * Attach the input controls to a specific dom element to get the input from.
  104733. * @param element Defines the element the controls should be listened from
  104734. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104735. */
  104736. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104737. private _orientationChanged;
  104738. private _deviceOrientation;
  104739. /**
  104740. * Detach the current controls from the specified dom element.
  104741. * @param element Defines the element to stop listening the inputs from
  104742. */
  104743. detachControl(element: Nullable<HTMLElement>): void;
  104744. /**
  104745. * Update the current camera state depending on the inputs that have been used this frame.
  104746. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104747. */
  104748. checkInputs(): void;
  104749. /**
  104750. * Gets the class name of the current intput.
  104751. * @returns the class name
  104752. */
  104753. getClassName(): string;
  104754. /**
  104755. * Get the friendly name associated with the input class.
  104756. * @returns the input friendly name
  104757. */
  104758. getSimpleName(): string;
  104759. }
  104760. }
  104761. declare module BABYLON {
  104762. /**
  104763. * Manage the gamepad inputs to control a free camera.
  104764. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104765. */
  104766. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  104767. /**
  104768. * Define the camera the input is attached to.
  104769. */
  104770. camera: FreeCamera;
  104771. /**
  104772. * Define the Gamepad controlling the input
  104773. */
  104774. gamepad: Nullable<Gamepad>;
  104775. /**
  104776. * Defines the gamepad rotation sensiblity.
  104777. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104778. */
  104779. gamepadAngularSensibility: number;
  104780. /**
  104781. * Defines the gamepad move sensiblity.
  104782. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104783. */
  104784. gamepadMoveSensibility: number;
  104785. private _onGamepadConnectedObserver;
  104786. private _onGamepadDisconnectedObserver;
  104787. private _cameraTransform;
  104788. private _deltaTransform;
  104789. private _vector3;
  104790. private _vector2;
  104791. /**
  104792. * Attach the input controls to a specific dom element to get the input from.
  104793. * @param element Defines the element the controls should be listened from
  104794. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104795. */
  104796. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104797. /**
  104798. * Detach the current controls from the specified dom element.
  104799. * @param element Defines the element to stop listening the inputs from
  104800. */
  104801. detachControl(element: Nullable<HTMLElement>): void;
  104802. /**
  104803. * Update the current camera state depending on the inputs that have been used this frame.
  104804. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104805. */
  104806. checkInputs(): void;
  104807. /**
  104808. * Gets the class name of the current intput.
  104809. * @returns the class name
  104810. */
  104811. getClassName(): string;
  104812. /**
  104813. * Get the friendly name associated with the input class.
  104814. * @returns the input friendly name
  104815. */
  104816. getSimpleName(): string;
  104817. }
  104818. }
  104819. declare module BABYLON {
  104820. /**
  104821. * Defines the potential axis of a Joystick
  104822. */
  104823. export enum JoystickAxis {
  104824. /** X axis */
  104825. X = 0,
  104826. /** Y axis */
  104827. Y = 1,
  104828. /** Z axis */
  104829. Z = 2
  104830. }
  104831. /**
  104832. * Class used to define virtual joystick (used in touch mode)
  104833. */
  104834. export class VirtualJoystick {
  104835. /**
  104836. * Gets or sets a boolean indicating that left and right values must be inverted
  104837. */
  104838. reverseLeftRight: boolean;
  104839. /**
  104840. * Gets or sets a boolean indicating that up and down values must be inverted
  104841. */
  104842. reverseUpDown: boolean;
  104843. /**
  104844. * Gets the offset value for the position (ie. the change of the position value)
  104845. */
  104846. deltaPosition: Vector3;
  104847. /**
  104848. * Gets a boolean indicating if the virtual joystick was pressed
  104849. */
  104850. pressed: boolean;
  104851. /**
  104852. * Canvas the virtual joystick will render onto, default z-index of this is 5
  104853. */
  104854. static Canvas: Nullable<HTMLCanvasElement>;
  104855. private static _globalJoystickIndex;
  104856. private static vjCanvasContext;
  104857. private static vjCanvasWidth;
  104858. private static vjCanvasHeight;
  104859. private static halfWidth;
  104860. private _action;
  104861. private _axisTargetedByLeftAndRight;
  104862. private _axisTargetedByUpAndDown;
  104863. private _joystickSensibility;
  104864. private _inversedSensibility;
  104865. private _joystickPointerID;
  104866. private _joystickColor;
  104867. private _joystickPointerPos;
  104868. private _joystickPreviousPointerPos;
  104869. private _joystickPointerStartPos;
  104870. private _deltaJoystickVector;
  104871. private _leftJoystick;
  104872. private _touches;
  104873. private _onPointerDownHandlerRef;
  104874. private _onPointerMoveHandlerRef;
  104875. private _onPointerUpHandlerRef;
  104876. private _onResize;
  104877. /**
  104878. * Creates a new virtual joystick
  104879. * @param leftJoystick defines that the joystick is for left hand (false by default)
  104880. */
  104881. constructor(leftJoystick?: boolean);
  104882. /**
  104883. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  104884. * @param newJoystickSensibility defines the new sensibility
  104885. */
  104886. setJoystickSensibility(newJoystickSensibility: number): void;
  104887. private _onPointerDown;
  104888. private _onPointerMove;
  104889. private _onPointerUp;
  104890. /**
  104891. * Change the color of the virtual joystick
  104892. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  104893. */
  104894. setJoystickColor(newColor: string): void;
  104895. /**
  104896. * Defines a callback to call when the joystick is touched
  104897. * @param action defines the callback
  104898. */
  104899. setActionOnTouch(action: () => any): void;
  104900. /**
  104901. * Defines which axis you'd like to control for left & right
  104902. * @param axis defines the axis to use
  104903. */
  104904. setAxisForLeftRight(axis: JoystickAxis): void;
  104905. /**
  104906. * Defines which axis you'd like to control for up & down
  104907. * @param axis defines the axis to use
  104908. */
  104909. setAxisForUpDown(axis: JoystickAxis): void;
  104910. private _drawVirtualJoystick;
  104911. /**
  104912. * Release internal HTML canvas
  104913. */
  104914. releaseCanvas(): void;
  104915. }
  104916. }
  104917. declare module BABYLON {
  104918. interface FreeCameraInputsManager {
  104919. /**
  104920. * Add virtual joystick input support to the input manager.
  104921. * @returns the current input manager
  104922. */
  104923. addVirtualJoystick(): FreeCameraInputsManager;
  104924. }
  104925. /**
  104926. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  104927. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104928. */
  104929. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  104930. /**
  104931. * Defines the camera the input is attached to.
  104932. */
  104933. camera: FreeCamera;
  104934. private _leftjoystick;
  104935. private _rightjoystick;
  104936. /**
  104937. * Gets the left stick of the virtual joystick.
  104938. * @returns The virtual Joystick
  104939. */
  104940. getLeftJoystick(): VirtualJoystick;
  104941. /**
  104942. * Gets the right stick of the virtual joystick.
  104943. * @returns The virtual Joystick
  104944. */
  104945. getRightJoystick(): VirtualJoystick;
  104946. /**
  104947. * Update the current camera state depending on the inputs that have been used this frame.
  104948. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104949. */
  104950. checkInputs(): void;
  104951. /**
  104952. * Attach the input controls to a specific dom element to get the input from.
  104953. * @param element Defines the element the controls should be listened from
  104954. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104955. */
  104956. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104957. /**
  104958. * Detach the current controls from the specified dom element.
  104959. * @param element Defines the element to stop listening the inputs from
  104960. */
  104961. detachControl(element: Nullable<HTMLElement>): void;
  104962. /**
  104963. * Gets the class name of the current intput.
  104964. * @returns the class name
  104965. */
  104966. getClassName(): string;
  104967. /**
  104968. * Get the friendly name associated with the input class.
  104969. * @returns the input friendly name
  104970. */
  104971. getSimpleName(): string;
  104972. }
  104973. }
  104974. declare module BABYLON {
  104975. /**
  104976. * This represents a FPS type of camera controlled by touch.
  104977. * This is like a universal camera minus the Gamepad controls.
  104978. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104979. */
  104980. export class TouchCamera extends FreeCamera {
  104981. /**
  104982. * Defines the touch sensibility for rotation.
  104983. * The higher the faster.
  104984. */
  104985. touchAngularSensibility: number;
  104986. /**
  104987. * Defines the touch sensibility for move.
  104988. * The higher the faster.
  104989. */
  104990. touchMoveSensibility: number;
  104991. /**
  104992. * Instantiates a new touch camera.
  104993. * This represents a FPS type of camera controlled by touch.
  104994. * This is like a universal camera minus the Gamepad controls.
  104995. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104996. * @param name Define the name of the camera in the scene
  104997. * @param position Define the start position of the camera in the scene
  104998. * @param scene Define the scene the camera belongs to
  104999. */
  105000. constructor(name: string, position: Vector3, scene: Scene);
  105001. /**
  105002. * Gets the current object class name.
  105003. * @return the class name
  105004. */
  105005. getClassName(): string;
  105006. /** @hidden */
  105007. _setupInputs(): void;
  105008. }
  105009. }
  105010. declare module BABYLON {
  105011. /**
  105012. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  105013. * being tilted forward or back and left or right.
  105014. */
  105015. export class DeviceOrientationCamera extends FreeCamera {
  105016. private _initialQuaternion;
  105017. private _quaternionCache;
  105018. private _tmpDragQuaternion;
  105019. private _disablePointerInputWhenUsingDeviceOrientation;
  105020. /**
  105021. * Creates a new device orientation camera
  105022. * @param name The name of the camera
  105023. * @param position The start position camera
  105024. * @param scene The scene the camera belongs to
  105025. */
  105026. constructor(name: string, position: Vector3, scene: Scene);
  105027. /**
  105028. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  105029. */
  105030. disablePointerInputWhenUsingDeviceOrientation: boolean;
  105031. private _dragFactor;
  105032. /**
  105033. * Enabled turning on the y axis when the orientation sensor is active
  105034. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  105035. */
  105036. enableHorizontalDragging(dragFactor?: number): void;
  105037. /**
  105038. * Gets the current instance class name ("DeviceOrientationCamera").
  105039. * This helps avoiding instanceof at run time.
  105040. * @returns the class name
  105041. */
  105042. getClassName(): string;
  105043. /**
  105044. * @hidden
  105045. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  105046. */
  105047. _checkInputs(): void;
  105048. /**
  105049. * Reset the camera to its default orientation on the specified axis only.
  105050. * @param axis The axis to reset
  105051. */
  105052. resetToCurrentRotation(axis?: Axis): void;
  105053. }
  105054. }
  105055. declare module BABYLON {
  105056. /**
  105057. * Defines supported buttons for XBox360 compatible gamepads
  105058. */
  105059. export enum Xbox360Button {
  105060. /** A */
  105061. A = 0,
  105062. /** B */
  105063. B = 1,
  105064. /** X */
  105065. X = 2,
  105066. /** Y */
  105067. Y = 3,
  105068. /** Start */
  105069. Start = 4,
  105070. /** Back */
  105071. Back = 5,
  105072. /** Left button */
  105073. LB = 6,
  105074. /** Right button */
  105075. RB = 7,
  105076. /** Left stick */
  105077. LeftStick = 8,
  105078. /** Right stick */
  105079. RightStick = 9
  105080. }
  105081. /** Defines values for XBox360 DPad */
  105082. export enum Xbox360Dpad {
  105083. /** Up */
  105084. Up = 0,
  105085. /** Down */
  105086. Down = 1,
  105087. /** Left */
  105088. Left = 2,
  105089. /** Right */
  105090. Right = 3
  105091. }
  105092. /**
  105093. * Defines a XBox360 gamepad
  105094. */
  105095. export class Xbox360Pad extends Gamepad {
  105096. private _leftTrigger;
  105097. private _rightTrigger;
  105098. private _onlefttriggerchanged;
  105099. private _onrighttriggerchanged;
  105100. private _onbuttondown;
  105101. private _onbuttonup;
  105102. private _ondpaddown;
  105103. private _ondpadup;
  105104. /** Observable raised when a button is pressed */
  105105. onButtonDownObservable: Observable<Xbox360Button>;
  105106. /** Observable raised when a button is released */
  105107. onButtonUpObservable: Observable<Xbox360Button>;
  105108. /** Observable raised when a pad is pressed */
  105109. onPadDownObservable: Observable<Xbox360Dpad>;
  105110. /** Observable raised when a pad is released */
  105111. onPadUpObservable: Observable<Xbox360Dpad>;
  105112. private _buttonA;
  105113. private _buttonB;
  105114. private _buttonX;
  105115. private _buttonY;
  105116. private _buttonBack;
  105117. private _buttonStart;
  105118. private _buttonLB;
  105119. private _buttonRB;
  105120. private _buttonLeftStick;
  105121. private _buttonRightStick;
  105122. private _dPadUp;
  105123. private _dPadDown;
  105124. private _dPadLeft;
  105125. private _dPadRight;
  105126. private _isXboxOnePad;
  105127. /**
  105128. * Creates a new XBox360 gamepad object
  105129. * @param id defines the id of this gamepad
  105130. * @param index defines its index
  105131. * @param gamepad defines the internal HTML gamepad object
  105132. * @param xboxOne defines if it is a XBox One gamepad
  105133. */
  105134. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  105135. /**
  105136. * Defines the callback to call when left trigger is pressed
  105137. * @param callback defines the callback to use
  105138. */
  105139. onlefttriggerchanged(callback: (value: number) => void): void;
  105140. /**
  105141. * Defines the callback to call when right trigger is pressed
  105142. * @param callback defines the callback to use
  105143. */
  105144. onrighttriggerchanged(callback: (value: number) => void): void;
  105145. /**
  105146. * Gets the left trigger value
  105147. */
  105148. /**
  105149. * Sets the left trigger value
  105150. */
  105151. leftTrigger: number;
  105152. /**
  105153. * Gets the right trigger value
  105154. */
  105155. /**
  105156. * Sets the right trigger value
  105157. */
  105158. rightTrigger: number;
  105159. /**
  105160. * Defines the callback to call when a button is pressed
  105161. * @param callback defines the callback to use
  105162. */
  105163. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  105164. /**
  105165. * Defines the callback to call when a button is released
  105166. * @param callback defines the callback to use
  105167. */
  105168. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  105169. /**
  105170. * Defines the callback to call when a pad is pressed
  105171. * @param callback defines the callback to use
  105172. */
  105173. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  105174. /**
  105175. * Defines the callback to call when a pad is released
  105176. * @param callback defines the callback to use
  105177. */
  105178. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  105179. private _setButtonValue;
  105180. private _setDPadValue;
  105181. /**
  105182. * Gets the value of the `A` button
  105183. */
  105184. /**
  105185. * Sets the value of the `A` button
  105186. */
  105187. buttonA: number;
  105188. /**
  105189. * Gets the value of the `B` button
  105190. */
  105191. /**
  105192. * Sets the value of the `B` button
  105193. */
  105194. buttonB: number;
  105195. /**
  105196. * Gets the value of the `X` button
  105197. */
  105198. /**
  105199. * Sets the value of the `X` button
  105200. */
  105201. buttonX: number;
  105202. /**
  105203. * Gets the value of the `Y` button
  105204. */
  105205. /**
  105206. * Sets the value of the `Y` button
  105207. */
  105208. buttonY: number;
  105209. /**
  105210. * Gets the value of the `Start` button
  105211. */
  105212. /**
  105213. * Sets the value of the `Start` button
  105214. */
  105215. buttonStart: number;
  105216. /**
  105217. * Gets the value of the `Back` button
  105218. */
  105219. /**
  105220. * Sets the value of the `Back` button
  105221. */
  105222. buttonBack: number;
  105223. /**
  105224. * Gets the value of the `Left` button
  105225. */
  105226. /**
  105227. * Sets the value of the `Left` button
  105228. */
  105229. buttonLB: number;
  105230. /**
  105231. * Gets the value of the `Right` button
  105232. */
  105233. /**
  105234. * Sets the value of the `Right` button
  105235. */
  105236. buttonRB: number;
  105237. /**
  105238. * Gets the value of the Left joystick
  105239. */
  105240. /**
  105241. * Sets the value of the Left joystick
  105242. */
  105243. buttonLeftStick: number;
  105244. /**
  105245. * Gets the value of the Right joystick
  105246. */
  105247. /**
  105248. * Sets the value of the Right joystick
  105249. */
  105250. buttonRightStick: number;
  105251. /**
  105252. * Gets the value of D-pad up
  105253. */
  105254. /**
  105255. * Sets the value of D-pad up
  105256. */
  105257. dPadUp: number;
  105258. /**
  105259. * Gets the value of D-pad down
  105260. */
  105261. /**
  105262. * Sets the value of D-pad down
  105263. */
  105264. dPadDown: number;
  105265. /**
  105266. * Gets the value of D-pad left
  105267. */
  105268. /**
  105269. * Sets the value of D-pad left
  105270. */
  105271. dPadLeft: number;
  105272. /**
  105273. * Gets the value of D-pad right
  105274. */
  105275. /**
  105276. * Sets the value of D-pad right
  105277. */
  105278. dPadRight: number;
  105279. /**
  105280. * Force the gamepad to synchronize with device values
  105281. */
  105282. update(): void;
  105283. /**
  105284. * Disposes the gamepad
  105285. */
  105286. dispose(): void;
  105287. }
  105288. }
  105289. declare module BABYLON {
  105290. /**
  105291. * Defines supported buttons for DualShock compatible gamepads
  105292. */
  105293. export enum DualShockButton {
  105294. /** Cross */
  105295. Cross = 0,
  105296. /** Circle */
  105297. Circle = 1,
  105298. /** Square */
  105299. Square = 2,
  105300. /** Triangle */
  105301. Triangle = 3,
  105302. /** Options */
  105303. Options = 4,
  105304. /** Share */
  105305. Share = 5,
  105306. /** L1 */
  105307. L1 = 6,
  105308. /** R1 */
  105309. R1 = 7,
  105310. /** Left stick */
  105311. LeftStick = 8,
  105312. /** Right stick */
  105313. RightStick = 9
  105314. }
  105315. /** Defines values for DualShock DPad */
  105316. export enum DualShockDpad {
  105317. /** Up */
  105318. Up = 0,
  105319. /** Down */
  105320. Down = 1,
  105321. /** Left */
  105322. Left = 2,
  105323. /** Right */
  105324. Right = 3
  105325. }
  105326. /**
  105327. * Defines a DualShock gamepad
  105328. */
  105329. export class DualShockPad extends Gamepad {
  105330. private _leftTrigger;
  105331. private _rightTrigger;
  105332. private _onlefttriggerchanged;
  105333. private _onrighttriggerchanged;
  105334. private _onbuttondown;
  105335. private _onbuttonup;
  105336. private _ondpaddown;
  105337. private _ondpadup;
  105338. /** Observable raised when a button is pressed */
  105339. onButtonDownObservable: Observable<DualShockButton>;
  105340. /** Observable raised when a button is released */
  105341. onButtonUpObservable: Observable<DualShockButton>;
  105342. /** Observable raised when a pad is pressed */
  105343. onPadDownObservable: Observable<DualShockDpad>;
  105344. /** Observable raised when a pad is released */
  105345. onPadUpObservable: Observable<DualShockDpad>;
  105346. private _buttonCross;
  105347. private _buttonCircle;
  105348. private _buttonSquare;
  105349. private _buttonTriangle;
  105350. private _buttonShare;
  105351. private _buttonOptions;
  105352. private _buttonL1;
  105353. private _buttonR1;
  105354. private _buttonLeftStick;
  105355. private _buttonRightStick;
  105356. private _dPadUp;
  105357. private _dPadDown;
  105358. private _dPadLeft;
  105359. private _dPadRight;
  105360. /**
  105361. * Creates a new DualShock gamepad object
  105362. * @param id defines the id of this gamepad
  105363. * @param index defines its index
  105364. * @param gamepad defines the internal HTML gamepad object
  105365. */
  105366. constructor(id: string, index: number, gamepad: any);
  105367. /**
  105368. * Defines the callback to call when left trigger is pressed
  105369. * @param callback defines the callback to use
  105370. */
  105371. onlefttriggerchanged(callback: (value: number) => void): void;
  105372. /**
  105373. * Defines the callback to call when right trigger is pressed
  105374. * @param callback defines the callback to use
  105375. */
  105376. onrighttriggerchanged(callback: (value: number) => void): void;
  105377. /**
  105378. * Gets the left trigger value
  105379. */
  105380. /**
  105381. * Sets the left trigger value
  105382. */
  105383. leftTrigger: number;
  105384. /**
  105385. * Gets the right trigger value
  105386. */
  105387. /**
  105388. * Sets the right trigger value
  105389. */
  105390. rightTrigger: number;
  105391. /**
  105392. * Defines the callback to call when a button is pressed
  105393. * @param callback defines the callback to use
  105394. */
  105395. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  105396. /**
  105397. * Defines the callback to call when a button is released
  105398. * @param callback defines the callback to use
  105399. */
  105400. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  105401. /**
  105402. * Defines the callback to call when a pad is pressed
  105403. * @param callback defines the callback to use
  105404. */
  105405. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  105406. /**
  105407. * Defines the callback to call when a pad is released
  105408. * @param callback defines the callback to use
  105409. */
  105410. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  105411. private _setButtonValue;
  105412. private _setDPadValue;
  105413. /**
  105414. * Gets the value of the `Cross` button
  105415. */
  105416. /**
  105417. * Sets the value of the `Cross` button
  105418. */
  105419. buttonCross: number;
  105420. /**
  105421. * Gets the value of the `Circle` button
  105422. */
  105423. /**
  105424. * Sets the value of the `Circle` button
  105425. */
  105426. buttonCircle: number;
  105427. /**
  105428. * Gets the value of the `Square` button
  105429. */
  105430. /**
  105431. * Sets the value of the `Square` button
  105432. */
  105433. buttonSquare: number;
  105434. /**
  105435. * Gets the value of the `Triangle` button
  105436. */
  105437. /**
  105438. * Sets the value of the `Triangle` button
  105439. */
  105440. buttonTriangle: number;
  105441. /**
  105442. * Gets the value of the `Options` button
  105443. */
  105444. /**
  105445. * Sets the value of the `Options` button
  105446. */
  105447. buttonOptions: number;
  105448. /**
  105449. * Gets the value of the `Share` button
  105450. */
  105451. /**
  105452. * Sets the value of the `Share` button
  105453. */
  105454. buttonShare: number;
  105455. /**
  105456. * Gets the value of the `L1` button
  105457. */
  105458. /**
  105459. * Sets the value of the `L1` button
  105460. */
  105461. buttonL1: number;
  105462. /**
  105463. * Gets the value of the `R1` button
  105464. */
  105465. /**
  105466. * Sets the value of the `R1` button
  105467. */
  105468. buttonR1: number;
  105469. /**
  105470. * Gets the value of the Left joystick
  105471. */
  105472. /**
  105473. * Sets the value of the Left joystick
  105474. */
  105475. buttonLeftStick: number;
  105476. /**
  105477. * Gets the value of the Right joystick
  105478. */
  105479. /**
  105480. * Sets the value of the Right joystick
  105481. */
  105482. buttonRightStick: number;
  105483. /**
  105484. * Gets the value of D-pad up
  105485. */
  105486. /**
  105487. * Sets the value of D-pad up
  105488. */
  105489. dPadUp: number;
  105490. /**
  105491. * Gets the value of D-pad down
  105492. */
  105493. /**
  105494. * Sets the value of D-pad down
  105495. */
  105496. dPadDown: number;
  105497. /**
  105498. * Gets the value of D-pad left
  105499. */
  105500. /**
  105501. * Sets the value of D-pad left
  105502. */
  105503. dPadLeft: number;
  105504. /**
  105505. * Gets the value of D-pad right
  105506. */
  105507. /**
  105508. * Sets the value of D-pad right
  105509. */
  105510. dPadRight: number;
  105511. /**
  105512. * Force the gamepad to synchronize with device values
  105513. */
  105514. update(): void;
  105515. /**
  105516. * Disposes the gamepad
  105517. */
  105518. dispose(): void;
  105519. }
  105520. }
  105521. declare module BABYLON {
  105522. /**
  105523. * Manager for handling gamepads
  105524. */
  105525. export class GamepadManager {
  105526. private _scene?;
  105527. private _babylonGamepads;
  105528. private _oneGamepadConnected;
  105529. /** @hidden */
  105530. _isMonitoring: boolean;
  105531. private _gamepadEventSupported;
  105532. private _gamepadSupport;
  105533. /**
  105534. * observable to be triggered when the gamepad controller has been connected
  105535. */
  105536. onGamepadConnectedObservable: Observable<Gamepad>;
  105537. /**
  105538. * observable to be triggered when the gamepad controller has been disconnected
  105539. */
  105540. onGamepadDisconnectedObservable: Observable<Gamepad>;
  105541. private _onGamepadConnectedEvent;
  105542. private _onGamepadDisconnectedEvent;
  105543. /**
  105544. * Initializes the gamepad manager
  105545. * @param _scene BabylonJS scene
  105546. */
  105547. constructor(_scene?: Scene | undefined);
  105548. /**
  105549. * The gamepads in the game pad manager
  105550. */
  105551. readonly gamepads: Gamepad[];
  105552. /**
  105553. * Get the gamepad controllers based on type
  105554. * @param type The type of gamepad controller
  105555. * @returns Nullable gamepad
  105556. */
  105557. getGamepadByType(type?: number): Nullable<Gamepad>;
  105558. /**
  105559. * Disposes the gamepad manager
  105560. */
  105561. dispose(): void;
  105562. private _addNewGamepad;
  105563. private _startMonitoringGamepads;
  105564. private _stopMonitoringGamepads;
  105565. /** @hidden */
  105566. _checkGamepadsStatus(): void;
  105567. private _updateGamepadObjects;
  105568. }
  105569. }
  105570. declare module BABYLON {
  105571. interface Scene {
  105572. /** @hidden */
  105573. _gamepadManager: Nullable<GamepadManager>;
  105574. /**
  105575. * Gets the gamepad manager associated with the scene
  105576. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  105577. */
  105578. gamepadManager: GamepadManager;
  105579. }
  105580. /**
  105581. * Interface representing a free camera inputs manager
  105582. */
  105583. interface FreeCameraInputsManager {
  105584. /**
  105585. * Adds gamepad input support to the FreeCameraInputsManager.
  105586. * @returns the FreeCameraInputsManager
  105587. */
  105588. addGamepad(): FreeCameraInputsManager;
  105589. }
  105590. /**
  105591. * Interface representing an arc rotate camera inputs manager
  105592. */
  105593. interface ArcRotateCameraInputsManager {
  105594. /**
  105595. * Adds gamepad input support to the ArcRotateCamera InputManager.
  105596. * @returns the camera inputs manager
  105597. */
  105598. addGamepad(): ArcRotateCameraInputsManager;
  105599. }
  105600. /**
  105601. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  105602. */
  105603. export class GamepadSystemSceneComponent implements ISceneComponent {
  105604. /**
  105605. * The component name helpfull to identify the component in the list of scene components.
  105606. */
  105607. readonly name: string;
  105608. /**
  105609. * The scene the component belongs to.
  105610. */
  105611. scene: Scene;
  105612. /**
  105613. * Creates a new instance of the component for the given scene
  105614. * @param scene Defines the scene to register the component in
  105615. */
  105616. constructor(scene: Scene);
  105617. /**
  105618. * Registers the component in a given scene
  105619. */
  105620. register(): void;
  105621. /**
  105622. * Rebuilds the elements related to this component in case of
  105623. * context lost for instance.
  105624. */
  105625. rebuild(): void;
  105626. /**
  105627. * Disposes the component and the associated ressources
  105628. */
  105629. dispose(): void;
  105630. private _beforeCameraUpdate;
  105631. }
  105632. }
  105633. declare module BABYLON {
  105634. /**
  105635. * 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,
  105636. * which still works and will still be found in many Playgrounds.
  105637. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105638. */
  105639. export class UniversalCamera extends TouchCamera {
  105640. /**
  105641. * Defines the gamepad rotation sensiblity.
  105642. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105643. */
  105644. gamepadAngularSensibility: number;
  105645. /**
  105646. * Defines the gamepad move sensiblity.
  105647. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105648. */
  105649. gamepadMoveSensibility: number;
  105650. /**
  105651. * 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,
  105652. * which still works and will still be found in many Playgrounds.
  105653. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105654. * @param name Define the name of the camera in the scene
  105655. * @param position Define the start position of the camera in the scene
  105656. * @param scene Define the scene the camera belongs to
  105657. */
  105658. constructor(name: string, position: Vector3, scene: Scene);
  105659. /**
  105660. * Gets the current object class name.
  105661. * @return the class name
  105662. */
  105663. getClassName(): string;
  105664. }
  105665. }
  105666. declare module BABYLON {
  105667. /**
  105668. * This represents a FPS type of camera. This is only here for back compat purpose.
  105669. * Please use the UniversalCamera instead as both are identical.
  105670. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105671. */
  105672. export class GamepadCamera extends UniversalCamera {
  105673. /**
  105674. * Instantiates a new Gamepad Camera
  105675. * This represents a FPS type of camera. This is only here for back compat purpose.
  105676. * Please use the UniversalCamera instead as both are identical.
  105677. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105678. * @param name Define the name of the camera in the scene
  105679. * @param position Define the start position of the camera in the scene
  105680. * @param scene Define the scene the camera belongs to
  105681. */
  105682. constructor(name: string, position: Vector3, scene: Scene);
  105683. /**
  105684. * Gets the current object class name.
  105685. * @return the class name
  105686. */
  105687. getClassName(): string;
  105688. }
  105689. }
  105690. declare module BABYLON {
  105691. /** @hidden */
  105692. export var passPixelShader: {
  105693. name: string;
  105694. shader: string;
  105695. };
  105696. }
  105697. declare module BABYLON {
  105698. /** @hidden */
  105699. export var passCubePixelShader: {
  105700. name: string;
  105701. shader: string;
  105702. };
  105703. }
  105704. declare module BABYLON {
  105705. /**
  105706. * PassPostProcess which produces an output the same as it's input
  105707. */
  105708. export class PassPostProcess extends PostProcess {
  105709. /**
  105710. * Creates the PassPostProcess
  105711. * @param name The name of the effect.
  105712. * @param options The required width/height ratio to downsize to before computing the render pass.
  105713. * @param camera The camera to apply the render pass to.
  105714. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105715. * @param engine The engine which the post process will be applied. (default: current engine)
  105716. * @param reusable If the post process can be reused on the same frame. (default: false)
  105717. * @param textureType The type of texture to be used when performing the post processing.
  105718. * @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)
  105719. */
  105720. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105721. }
  105722. /**
  105723. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  105724. */
  105725. export class PassCubePostProcess extends PostProcess {
  105726. private _face;
  105727. /**
  105728. * Gets or sets the cube face to display.
  105729. * * 0 is +X
  105730. * * 1 is -X
  105731. * * 2 is +Y
  105732. * * 3 is -Y
  105733. * * 4 is +Z
  105734. * * 5 is -Z
  105735. */
  105736. face: number;
  105737. /**
  105738. * Creates the PassCubePostProcess
  105739. * @param name The name of the effect.
  105740. * @param options The required width/height ratio to downsize to before computing the render pass.
  105741. * @param camera The camera to apply the render pass to.
  105742. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105743. * @param engine The engine which the post process will be applied. (default: current engine)
  105744. * @param reusable If the post process can be reused on the same frame. (default: false)
  105745. * @param textureType The type of texture to be used when performing the post processing.
  105746. * @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)
  105747. */
  105748. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105749. }
  105750. }
  105751. declare module BABYLON {
  105752. /** @hidden */
  105753. export var anaglyphPixelShader: {
  105754. name: string;
  105755. shader: string;
  105756. };
  105757. }
  105758. declare module BABYLON {
  105759. /**
  105760. * Postprocess used to generate anaglyphic rendering
  105761. */
  105762. export class AnaglyphPostProcess extends PostProcess {
  105763. private _passedProcess;
  105764. /**
  105765. * Creates a new AnaglyphPostProcess
  105766. * @param name defines postprocess name
  105767. * @param options defines creation options or target ratio scale
  105768. * @param rigCameras defines cameras using this postprocess
  105769. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  105770. * @param engine defines hosting engine
  105771. * @param reusable defines if the postprocess will be reused multiple times per frame
  105772. */
  105773. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  105774. }
  105775. }
  105776. declare module BABYLON {
  105777. /**
  105778. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  105779. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105780. */
  105781. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  105782. /**
  105783. * Creates a new AnaglyphArcRotateCamera
  105784. * @param name defines camera name
  105785. * @param alpha defines alpha angle (in radians)
  105786. * @param beta defines beta angle (in radians)
  105787. * @param radius defines radius
  105788. * @param target defines camera target
  105789. * @param interaxialDistance defines distance between each color axis
  105790. * @param scene defines the hosting scene
  105791. */
  105792. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  105793. /**
  105794. * Gets camera class name
  105795. * @returns AnaglyphArcRotateCamera
  105796. */
  105797. getClassName(): string;
  105798. }
  105799. }
  105800. declare module BABYLON {
  105801. /**
  105802. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  105803. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105804. */
  105805. export class AnaglyphFreeCamera extends FreeCamera {
  105806. /**
  105807. * Creates a new AnaglyphFreeCamera
  105808. * @param name defines camera name
  105809. * @param position defines initial position
  105810. * @param interaxialDistance defines distance between each color axis
  105811. * @param scene defines the hosting scene
  105812. */
  105813. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105814. /**
  105815. * Gets camera class name
  105816. * @returns AnaglyphFreeCamera
  105817. */
  105818. getClassName(): string;
  105819. }
  105820. }
  105821. declare module BABYLON {
  105822. /**
  105823. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  105824. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105825. */
  105826. export class AnaglyphGamepadCamera extends GamepadCamera {
  105827. /**
  105828. * Creates a new AnaglyphGamepadCamera
  105829. * @param name defines camera name
  105830. * @param position defines initial position
  105831. * @param interaxialDistance defines distance between each color axis
  105832. * @param scene defines the hosting scene
  105833. */
  105834. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105835. /**
  105836. * Gets camera class name
  105837. * @returns AnaglyphGamepadCamera
  105838. */
  105839. getClassName(): string;
  105840. }
  105841. }
  105842. declare module BABYLON {
  105843. /**
  105844. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  105845. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105846. */
  105847. export class AnaglyphUniversalCamera extends UniversalCamera {
  105848. /**
  105849. * Creates a new AnaglyphUniversalCamera
  105850. * @param name defines camera name
  105851. * @param position defines initial position
  105852. * @param interaxialDistance defines distance between each color axis
  105853. * @param scene defines the hosting scene
  105854. */
  105855. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105856. /**
  105857. * Gets camera class name
  105858. * @returns AnaglyphUniversalCamera
  105859. */
  105860. getClassName(): string;
  105861. }
  105862. }
  105863. declare module BABYLON {
  105864. /** @hidden */
  105865. export var stereoscopicInterlacePixelShader: {
  105866. name: string;
  105867. shader: string;
  105868. };
  105869. }
  105870. declare module BABYLON {
  105871. /**
  105872. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  105873. */
  105874. export class StereoscopicInterlacePostProcess extends PostProcess {
  105875. private _stepSize;
  105876. private _passedProcess;
  105877. /**
  105878. * Initializes a StereoscopicInterlacePostProcess
  105879. * @param name The name of the effect.
  105880. * @param rigCameras The rig cameras to be appled to the post process
  105881. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  105882. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105883. * @param engine The engine which the post process will be applied. (default: current engine)
  105884. * @param reusable If the post process can be reused on the same frame. (default: false)
  105885. */
  105886. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105887. }
  105888. }
  105889. declare module BABYLON {
  105890. /**
  105891. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  105892. * @see http://doc.babylonjs.com/features/cameras
  105893. */
  105894. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  105895. /**
  105896. * Creates a new StereoscopicArcRotateCamera
  105897. * @param name defines camera name
  105898. * @param alpha defines alpha angle (in radians)
  105899. * @param beta defines beta angle (in radians)
  105900. * @param radius defines radius
  105901. * @param target defines camera target
  105902. * @param interaxialDistance defines distance between each color axis
  105903. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105904. * @param scene defines the hosting scene
  105905. */
  105906. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105907. /**
  105908. * Gets camera class name
  105909. * @returns StereoscopicArcRotateCamera
  105910. */
  105911. getClassName(): string;
  105912. }
  105913. }
  105914. declare module BABYLON {
  105915. /**
  105916. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  105917. * @see http://doc.babylonjs.com/features/cameras
  105918. */
  105919. export class StereoscopicFreeCamera extends FreeCamera {
  105920. /**
  105921. * Creates a new StereoscopicFreeCamera
  105922. * @param name defines camera name
  105923. * @param position defines initial position
  105924. * @param interaxialDistance defines distance between each color axis
  105925. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105926. * @param scene defines the hosting scene
  105927. */
  105928. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105929. /**
  105930. * Gets camera class name
  105931. * @returns StereoscopicFreeCamera
  105932. */
  105933. getClassName(): string;
  105934. }
  105935. }
  105936. declare module BABYLON {
  105937. /**
  105938. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  105939. * @see http://doc.babylonjs.com/features/cameras
  105940. */
  105941. export class StereoscopicGamepadCamera extends GamepadCamera {
  105942. /**
  105943. * Creates a new StereoscopicGamepadCamera
  105944. * @param name defines camera name
  105945. * @param position defines initial position
  105946. * @param interaxialDistance defines distance between each color axis
  105947. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105948. * @param scene defines the hosting scene
  105949. */
  105950. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105951. /**
  105952. * Gets camera class name
  105953. * @returns StereoscopicGamepadCamera
  105954. */
  105955. getClassName(): string;
  105956. }
  105957. }
  105958. declare module BABYLON {
  105959. /**
  105960. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  105961. * @see http://doc.babylonjs.com/features/cameras
  105962. */
  105963. export class StereoscopicUniversalCamera extends UniversalCamera {
  105964. /**
  105965. * Creates a new StereoscopicUniversalCamera
  105966. * @param name defines camera name
  105967. * @param position defines initial position
  105968. * @param interaxialDistance defines distance between each color axis
  105969. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105970. * @param scene defines the hosting scene
  105971. */
  105972. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105973. /**
  105974. * Gets camera class name
  105975. * @returns StereoscopicUniversalCamera
  105976. */
  105977. getClassName(): string;
  105978. }
  105979. }
  105980. declare module BABYLON {
  105981. /**
  105982. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  105983. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105984. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105985. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105986. */
  105987. export class VirtualJoysticksCamera extends FreeCamera {
  105988. /**
  105989. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  105990. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105991. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105992. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105993. * @param name Define the name of the camera in the scene
  105994. * @param position Define the start position of the camera in the scene
  105995. * @param scene Define the scene the camera belongs to
  105996. */
  105997. constructor(name: string, position: Vector3, scene: Scene);
  105998. /**
  105999. * Gets the current object class name.
  106000. * @return the class name
  106001. */
  106002. getClassName(): string;
  106003. }
  106004. }
  106005. declare module BABYLON {
  106006. /**
  106007. * This represents all the required metrics to create a VR camera.
  106008. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  106009. */
  106010. export class VRCameraMetrics {
  106011. /**
  106012. * Define the horizontal resolution off the screen.
  106013. */
  106014. hResolution: number;
  106015. /**
  106016. * Define the vertical resolution off the screen.
  106017. */
  106018. vResolution: number;
  106019. /**
  106020. * Define the horizontal screen size.
  106021. */
  106022. hScreenSize: number;
  106023. /**
  106024. * Define the vertical screen size.
  106025. */
  106026. vScreenSize: number;
  106027. /**
  106028. * Define the vertical screen center position.
  106029. */
  106030. vScreenCenter: number;
  106031. /**
  106032. * Define the distance of the eyes to the screen.
  106033. */
  106034. eyeToScreenDistance: number;
  106035. /**
  106036. * Define the distance between both lenses
  106037. */
  106038. lensSeparationDistance: number;
  106039. /**
  106040. * Define the distance between both viewer's eyes.
  106041. */
  106042. interpupillaryDistance: number;
  106043. /**
  106044. * Define the distortion factor of the VR postprocess.
  106045. * Please, touch with care.
  106046. */
  106047. distortionK: number[];
  106048. /**
  106049. * Define the chromatic aberration correction factors for the VR post process.
  106050. */
  106051. chromaAbCorrection: number[];
  106052. /**
  106053. * Define the scale factor of the post process.
  106054. * The smaller the better but the slower.
  106055. */
  106056. postProcessScaleFactor: number;
  106057. /**
  106058. * Define an offset for the lens center.
  106059. */
  106060. lensCenterOffset: number;
  106061. /**
  106062. * Define if the current vr camera should compensate the distortion of the lense or not.
  106063. */
  106064. compensateDistortion: boolean;
  106065. /**
  106066. * Defines if multiview should be enabled when rendering (Default: false)
  106067. */
  106068. multiviewEnabled: boolean;
  106069. /**
  106070. * Gets the rendering aspect ratio based on the provided resolutions.
  106071. */
  106072. readonly aspectRatio: number;
  106073. /**
  106074. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  106075. */
  106076. readonly aspectRatioFov: number;
  106077. /**
  106078. * @hidden
  106079. */
  106080. readonly leftHMatrix: Matrix;
  106081. /**
  106082. * @hidden
  106083. */
  106084. readonly rightHMatrix: Matrix;
  106085. /**
  106086. * @hidden
  106087. */
  106088. readonly leftPreViewMatrix: Matrix;
  106089. /**
  106090. * @hidden
  106091. */
  106092. readonly rightPreViewMatrix: Matrix;
  106093. /**
  106094. * Get the default VRMetrics based on the most generic setup.
  106095. * @returns the default vr metrics
  106096. */
  106097. static GetDefault(): VRCameraMetrics;
  106098. }
  106099. }
  106100. declare module BABYLON {
  106101. /** @hidden */
  106102. export var vrDistortionCorrectionPixelShader: {
  106103. name: string;
  106104. shader: string;
  106105. };
  106106. }
  106107. declare module BABYLON {
  106108. /**
  106109. * VRDistortionCorrectionPostProcess used for mobile VR
  106110. */
  106111. export class VRDistortionCorrectionPostProcess extends PostProcess {
  106112. private _isRightEye;
  106113. private _distortionFactors;
  106114. private _postProcessScaleFactor;
  106115. private _lensCenterOffset;
  106116. private _scaleIn;
  106117. private _scaleFactor;
  106118. private _lensCenter;
  106119. /**
  106120. * Initializes the VRDistortionCorrectionPostProcess
  106121. * @param name The name of the effect.
  106122. * @param camera The camera to apply the render pass to.
  106123. * @param isRightEye If this is for the right eye distortion
  106124. * @param vrMetrics All the required metrics for the VR camera
  106125. */
  106126. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  106127. }
  106128. }
  106129. declare module BABYLON {
  106130. /**
  106131. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  106132. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106133. */
  106134. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  106135. /**
  106136. * Creates a new VRDeviceOrientationArcRotateCamera
  106137. * @param name defines camera name
  106138. * @param alpha defines the camera rotation along the logitudinal axis
  106139. * @param beta defines the camera rotation along the latitudinal axis
  106140. * @param radius defines the camera distance from its target
  106141. * @param target defines the camera target
  106142. * @param scene defines the scene the camera belongs to
  106143. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106144. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106145. */
  106146. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106147. /**
  106148. * Gets camera class name
  106149. * @returns VRDeviceOrientationArcRotateCamera
  106150. */
  106151. getClassName(): string;
  106152. }
  106153. }
  106154. declare module BABYLON {
  106155. /**
  106156. * Camera used to simulate VR rendering (based on FreeCamera)
  106157. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106158. */
  106159. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  106160. /**
  106161. * Creates a new VRDeviceOrientationFreeCamera
  106162. * @param name defines camera name
  106163. * @param position defines the start position of the camera
  106164. * @param scene defines the scene the camera belongs to
  106165. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106166. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106167. */
  106168. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106169. /**
  106170. * Gets camera class name
  106171. * @returns VRDeviceOrientationFreeCamera
  106172. */
  106173. getClassName(): string;
  106174. }
  106175. }
  106176. declare module BABYLON {
  106177. /**
  106178. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  106179. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106180. */
  106181. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  106182. /**
  106183. * Creates a new VRDeviceOrientationGamepadCamera
  106184. * @param name defines camera name
  106185. * @param position defines the start position of the camera
  106186. * @param scene defines the scene the camera belongs to
  106187. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106188. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106189. */
  106190. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106191. /**
  106192. * Gets camera class name
  106193. * @returns VRDeviceOrientationGamepadCamera
  106194. */
  106195. getClassName(): string;
  106196. }
  106197. }
  106198. declare module BABYLON {
  106199. /**
  106200. * Base class of materials working in push mode in babylon JS
  106201. * @hidden
  106202. */
  106203. export class PushMaterial extends Material {
  106204. protected _activeEffect: Effect;
  106205. protected _normalMatrix: Matrix;
  106206. /**
  106207. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  106208. * This means that the material can keep using a previous shader while a new one is being compiled.
  106209. * This is mostly used when shader parallel compilation is supported (true by default)
  106210. */
  106211. allowShaderHotSwapping: boolean;
  106212. constructor(name: string, scene: Scene);
  106213. getEffect(): Effect;
  106214. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  106215. /**
  106216. * Binds the given world matrix to the active effect
  106217. *
  106218. * @param world the matrix to bind
  106219. */
  106220. bindOnlyWorldMatrix(world: Matrix): void;
  106221. /**
  106222. * Binds the given normal matrix to the active effect
  106223. *
  106224. * @param normalMatrix the matrix to bind
  106225. */
  106226. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  106227. bind(world: Matrix, mesh?: Mesh): void;
  106228. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  106229. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  106230. }
  106231. }
  106232. declare module BABYLON {
  106233. /**
  106234. * This groups all the flags used to control the materials channel.
  106235. */
  106236. export class MaterialFlags {
  106237. private static _DiffuseTextureEnabled;
  106238. /**
  106239. * Are diffuse textures enabled in the application.
  106240. */
  106241. static DiffuseTextureEnabled: boolean;
  106242. private static _AmbientTextureEnabled;
  106243. /**
  106244. * Are ambient textures enabled in the application.
  106245. */
  106246. static AmbientTextureEnabled: boolean;
  106247. private static _OpacityTextureEnabled;
  106248. /**
  106249. * Are opacity textures enabled in the application.
  106250. */
  106251. static OpacityTextureEnabled: boolean;
  106252. private static _ReflectionTextureEnabled;
  106253. /**
  106254. * Are reflection textures enabled in the application.
  106255. */
  106256. static ReflectionTextureEnabled: boolean;
  106257. private static _EmissiveTextureEnabled;
  106258. /**
  106259. * Are emissive textures enabled in the application.
  106260. */
  106261. static EmissiveTextureEnabled: boolean;
  106262. private static _SpecularTextureEnabled;
  106263. /**
  106264. * Are specular textures enabled in the application.
  106265. */
  106266. static SpecularTextureEnabled: boolean;
  106267. private static _BumpTextureEnabled;
  106268. /**
  106269. * Are bump textures enabled in the application.
  106270. */
  106271. static BumpTextureEnabled: boolean;
  106272. private static _LightmapTextureEnabled;
  106273. /**
  106274. * Are lightmap textures enabled in the application.
  106275. */
  106276. static LightmapTextureEnabled: boolean;
  106277. private static _RefractionTextureEnabled;
  106278. /**
  106279. * Are refraction textures enabled in the application.
  106280. */
  106281. static RefractionTextureEnabled: boolean;
  106282. private static _ColorGradingTextureEnabled;
  106283. /**
  106284. * Are color grading textures enabled in the application.
  106285. */
  106286. static ColorGradingTextureEnabled: boolean;
  106287. private static _FresnelEnabled;
  106288. /**
  106289. * Are fresnels enabled in the application.
  106290. */
  106291. static FresnelEnabled: boolean;
  106292. private static _ClearCoatTextureEnabled;
  106293. /**
  106294. * Are clear coat textures enabled in the application.
  106295. */
  106296. static ClearCoatTextureEnabled: boolean;
  106297. private static _ClearCoatBumpTextureEnabled;
  106298. /**
  106299. * Are clear coat bump textures enabled in the application.
  106300. */
  106301. static ClearCoatBumpTextureEnabled: boolean;
  106302. private static _ClearCoatTintTextureEnabled;
  106303. /**
  106304. * Are clear coat tint textures enabled in the application.
  106305. */
  106306. static ClearCoatTintTextureEnabled: boolean;
  106307. private static _SheenTextureEnabled;
  106308. /**
  106309. * Are sheen textures enabled in the application.
  106310. */
  106311. static SheenTextureEnabled: boolean;
  106312. private static _AnisotropicTextureEnabled;
  106313. /**
  106314. * Are anisotropic textures enabled in the application.
  106315. */
  106316. static AnisotropicTextureEnabled: boolean;
  106317. private static _ThicknessTextureEnabled;
  106318. /**
  106319. * Are thickness textures enabled in the application.
  106320. */
  106321. static ThicknessTextureEnabled: boolean;
  106322. }
  106323. }
  106324. declare module BABYLON {
  106325. /** @hidden */
  106326. export var defaultFragmentDeclaration: {
  106327. name: string;
  106328. shader: string;
  106329. };
  106330. }
  106331. declare module BABYLON {
  106332. /** @hidden */
  106333. export var defaultUboDeclaration: {
  106334. name: string;
  106335. shader: string;
  106336. };
  106337. }
  106338. declare module BABYLON {
  106339. /** @hidden */
  106340. export var lightFragmentDeclaration: {
  106341. name: string;
  106342. shader: string;
  106343. };
  106344. }
  106345. declare module BABYLON {
  106346. /** @hidden */
  106347. export var lightUboDeclaration: {
  106348. name: string;
  106349. shader: string;
  106350. };
  106351. }
  106352. declare module BABYLON {
  106353. /** @hidden */
  106354. export var lightsFragmentFunctions: {
  106355. name: string;
  106356. shader: string;
  106357. };
  106358. }
  106359. declare module BABYLON {
  106360. /** @hidden */
  106361. export var shadowsFragmentFunctions: {
  106362. name: string;
  106363. shader: string;
  106364. };
  106365. }
  106366. declare module BABYLON {
  106367. /** @hidden */
  106368. export var fresnelFunction: {
  106369. name: string;
  106370. shader: string;
  106371. };
  106372. }
  106373. declare module BABYLON {
  106374. /** @hidden */
  106375. export var reflectionFunction: {
  106376. name: string;
  106377. shader: string;
  106378. };
  106379. }
  106380. declare module BABYLON {
  106381. /** @hidden */
  106382. export var bumpFragmentFunctions: {
  106383. name: string;
  106384. shader: string;
  106385. };
  106386. }
  106387. declare module BABYLON {
  106388. /** @hidden */
  106389. export var logDepthDeclaration: {
  106390. name: string;
  106391. shader: string;
  106392. };
  106393. }
  106394. declare module BABYLON {
  106395. /** @hidden */
  106396. export var bumpFragment: {
  106397. name: string;
  106398. shader: string;
  106399. };
  106400. }
  106401. declare module BABYLON {
  106402. /** @hidden */
  106403. export var depthPrePass: {
  106404. name: string;
  106405. shader: string;
  106406. };
  106407. }
  106408. declare module BABYLON {
  106409. /** @hidden */
  106410. export var lightFragment: {
  106411. name: string;
  106412. shader: string;
  106413. };
  106414. }
  106415. declare module BABYLON {
  106416. /** @hidden */
  106417. export var logDepthFragment: {
  106418. name: string;
  106419. shader: string;
  106420. };
  106421. }
  106422. declare module BABYLON {
  106423. /** @hidden */
  106424. export var defaultPixelShader: {
  106425. name: string;
  106426. shader: string;
  106427. };
  106428. }
  106429. declare module BABYLON {
  106430. /** @hidden */
  106431. export var defaultVertexDeclaration: {
  106432. name: string;
  106433. shader: string;
  106434. };
  106435. }
  106436. declare module BABYLON {
  106437. /** @hidden */
  106438. export var bumpVertexDeclaration: {
  106439. name: string;
  106440. shader: string;
  106441. };
  106442. }
  106443. declare module BABYLON {
  106444. /** @hidden */
  106445. export var bumpVertex: {
  106446. name: string;
  106447. shader: string;
  106448. };
  106449. }
  106450. declare module BABYLON {
  106451. /** @hidden */
  106452. export var fogVertex: {
  106453. name: string;
  106454. shader: string;
  106455. };
  106456. }
  106457. declare module BABYLON {
  106458. /** @hidden */
  106459. export var shadowsVertex: {
  106460. name: string;
  106461. shader: string;
  106462. };
  106463. }
  106464. declare module BABYLON {
  106465. /** @hidden */
  106466. export var pointCloudVertex: {
  106467. name: string;
  106468. shader: string;
  106469. };
  106470. }
  106471. declare module BABYLON {
  106472. /** @hidden */
  106473. export var logDepthVertex: {
  106474. name: string;
  106475. shader: string;
  106476. };
  106477. }
  106478. declare module BABYLON {
  106479. /** @hidden */
  106480. export var defaultVertexShader: {
  106481. name: string;
  106482. shader: string;
  106483. };
  106484. }
  106485. declare module BABYLON {
  106486. /** @hidden */
  106487. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  106488. MAINUV1: boolean;
  106489. MAINUV2: boolean;
  106490. DIFFUSE: boolean;
  106491. DIFFUSEDIRECTUV: number;
  106492. AMBIENT: boolean;
  106493. AMBIENTDIRECTUV: number;
  106494. OPACITY: boolean;
  106495. OPACITYDIRECTUV: number;
  106496. OPACITYRGB: boolean;
  106497. REFLECTION: boolean;
  106498. EMISSIVE: boolean;
  106499. EMISSIVEDIRECTUV: number;
  106500. SPECULAR: boolean;
  106501. SPECULARDIRECTUV: number;
  106502. BUMP: boolean;
  106503. BUMPDIRECTUV: number;
  106504. PARALLAX: boolean;
  106505. PARALLAXOCCLUSION: boolean;
  106506. SPECULAROVERALPHA: boolean;
  106507. CLIPPLANE: boolean;
  106508. CLIPPLANE2: boolean;
  106509. CLIPPLANE3: boolean;
  106510. CLIPPLANE4: boolean;
  106511. ALPHATEST: boolean;
  106512. DEPTHPREPASS: boolean;
  106513. ALPHAFROMDIFFUSE: boolean;
  106514. POINTSIZE: boolean;
  106515. FOG: boolean;
  106516. SPECULARTERM: boolean;
  106517. DIFFUSEFRESNEL: boolean;
  106518. OPACITYFRESNEL: boolean;
  106519. REFLECTIONFRESNEL: boolean;
  106520. REFRACTIONFRESNEL: boolean;
  106521. EMISSIVEFRESNEL: boolean;
  106522. FRESNEL: boolean;
  106523. NORMAL: boolean;
  106524. UV1: boolean;
  106525. UV2: boolean;
  106526. VERTEXCOLOR: boolean;
  106527. VERTEXALPHA: boolean;
  106528. NUM_BONE_INFLUENCERS: number;
  106529. BonesPerMesh: number;
  106530. BONETEXTURE: boolean;
  106531. INSTANCES: boolean;
  106532. GLOSSINESS: boolean;
  106533. ROUGHNESS: boolean;
  106534. EMISSIVEASILLUMINATION: boolean;
  106535. LINKEMISSIVEWITHDIFFUSE: boolean;
  106536. REFLECTIONFRESNELFROMSPECULAR: boolean;
  106537. LIGHTMAP: boolean;
  106538. LIGHTMAPDIRECTUV: number;
  106539. OBJECTSPACE_NORMALMAP: boolean;
  106540. USELIGHTMAPASSHADOWMAP: boolean;
  106541. REFLECTIONMAP_3D: boolean;
  106542. REFLECTIONMAP_SPHERICAL: boolean;
  106543. REFLECTIONMAP_PLANAR: boolean;
  106544. REFLECTIONMAP_CUBIC: boolean;
  106545. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106546. REFLECTIONMAP_PROJECTION: boolean;
  106547. REFLECTIONMAP_SKYBOX: boolean;
  106548. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  106549. REFLECTIONMAP_EXPLICIT: boolean;
  106550. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106551. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106552. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106553. INVERTCUBICMAP: boolean;
  106554. LOGARITHMICDEPTH: boolean;
  106555. REFRACTION: boolean;
  106556. REFRACTIONMAP_3D: boolean;
  106557. REFLECTIONOVERALPHA: boolean;
  106558. TWOSIDEDLIGHTING: boolean;
  106559. SHADOWFLOAT: boolean;
  106560. MORPHTARGETS: boolean;
  106561. MORPHTARGETS_NORMAL: boolean;
  106562. MORPHTARGETS_TANGENT: boolean;
  106563. MORPHTARGETS_UV: boolean;
  106564. NUM_MORPH_INFLUENCERS: number;
  106565. NONUNIFORMSCALING: boolean;
  106566. PREMULTIPLYALPHA: boolean;
  106567. IMAGEPROCESSING: boolean;
  106568. VIGNETTE: boolean;
  106569. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106570. VIGNETTEBLENDMODEOPAQUE: boolean;
  106571. TONEMAPPING: boolean;
  106572. TONEMAPPING_ACES: boolean;
  106573. CONTRAST: boolean;
  106574. COLORCURVES: boolean;
  106575. COLORGRADING: boolean;
  106576. COLORGRADING3D: boolean;
  106577. SAMPLER3DGREENDEPTH: boolean;
  106578. SAMPLER3DBGRMAP: boolean;
  106579. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106580. MULTIVIEW: boolean;
  106581. /**
  106582. * If the reflection texture on this material is in linear color space
  106583. * @hidden
  106584. */
  106585. IS_REFLECTION_LINEAR: boolean;
  106586. /**
  106587. * If the refraction texture on this material is in linear color space
  106588. * @hidden
  106589. */
  106590. IS_REFRACTION_LINEAR: boolean;
  106591. EXPOSURE: boolean;
  106592. constructor();
  106593. setReflectionMode(modeToEnable: string): void;
  106594. }
  106595. /**
  106596. * This is the default material used in Babylon. It is the best trade off between quality
  106597. * and performances.
  106598. * @see http://doc.babylonjs.com/babylon101/materials
  106599. */
  106600. export class StandardMaterial extends PushMaterial {
  106601. private _diffuseTexture;
  106602. /**
  106603. * The basic texture of the material as viewed under a light.
  106604. */
  106605. diffuseTexture: Nullable<BaseTexture>;
  106606. private _ambientTexture;
  106607. /**
  106608. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  106609. */
  106610. ambientTexture: Nullable<BaseTexture>;
  106611. private _opacityTexture;
  106612. /**
  106613. * Define the transparency of the material from a texture.
  106614. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  106615. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  106616. */
  106617. opacityTexture: Nullable<BaseTexture>;
  106618. private _reflectionTexture;
  106619. /**
  106620. * Define the texture used to display the reflection.
  106621. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106622. */
  106623. reflectionTexture: Nullable<BaseTexture>;
  106624. private _emissiveTexture;
  106625. /**
  106626. * Define texture of the material as if self lit.
  106627. * This will be mixed in the final result even in the absence of light.
  106628. */
  106629. emissiveTexture: Nullable<BaseTexture>;
  106630. private _specularTexture;
  106631. /**
  106632. * Define how the color and intensity of the highlight given by the light in the material.
  106633. */
  106634. specularTexture: Nullable<BaseTexture>;
  106635. private _bumpTexture;
  106636. /**
  106637. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  106638. * 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.
  106639. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  106640. */
  106641. bumpTexture: Nullable<BaseTexture>;
  106642. private _lightmapTexture;
  106643. /**
  106644. * Complex lighting can be computationally expensive to compute at runtime.
  106645. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  106646. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  106647. */
  106648. lightmapTexture: Nullable<BaseTexture>;
  106649. private _refractionTexture;
  106650. /**
  106651. * Define the texture used to display the refraction.
  106652. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106653. */
  106654. refractionTexture: Nullable<BaseTexture>;
  106655. /**
  106656. * The color of the material lit by the environmental background lighting.
  106657. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  106658. */
  106659. ambientColor: Color3;
  106660. /**
  106661. * The basic color of the material as viewed under a light.
  106662. */
  106663. diffuseColor: Color3;
  106664. /**
  106665. * Define how the color and intensity of the highlight given by the light in the material.
  106666. */
  106667. specularColor: Color3;
  106668. /**
  106669. * Define the color of the material as if self lit.
  106670. * This will be mixed in the final result even in the absence of light.
  106671. */
  106672. emissiveColor: Color3;
  106673. /**
  106674. * Defines how sharp are the highlights in the material.
  106675. * The bigger the value the sharper giving a more glossy feeling to the result.
  106676. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  106677. */
  106678. specularPower: number;
  106679. private _useAlphaFromDiffuseTexture;
  106680. /**
  106681. * Does the transparency come from the diffuse texture alpha channel.
  106682. */
  106683. useAlphaFromDiffuseTexture: boolean;
  106684. private _useEmissiveAsIllumination;
  106685. /**
  106686. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  106687. */
  106688. useEmissiveAsIllumination: boolean;
  106689. private _linkEmissiveWithDiffuse;
  106690. /**
  106691. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  106692. * the emissive level when the final color is close to one.
  106693. */
  106694. linkEmissiveWithDiffuse: boolean;
  106695. private _useSpecularOverAlpha;
  106696. /**
  106697. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  106698. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106699. */
  106700. useSpecularOverAlpha: boolean;
  106701. private _useReflectionOverAlpha;
  106702. /**
  106703. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  106704. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  106705. */
  106706. useReflectionOverAlpha: boolean;
  106707. private _disableLighting;
  106708. /**
  106709. * Does lights from the scene impacts this material.
  106710. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  106711. */
  106712. disableLighting: boolean;
  106713. private _useObjectSpaceNormalMap;
  106714. /**
  106715. * Allows using an object space normal map (instead of tangent space).
  106716. */
  106717. useObjectSpaceNormalMap: boolean;
  106718. private _useParallax;
  106719. /**
  106720. * Is parallax enabled or not.
  106721. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106722. */
  106723. useParallax: boolean;
  106724. private _useParallaxOcclusion;
  106725. /**
  106726. * Is parallax occlusion enabled or not.
  106727. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  106728. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106729. */
  106730. useParallaxOcclusion: boolean;
  106731. /**
  106732. * 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.
  106733. */
  106734. parallaxScaleBias: number;
  106735. private _roughness;
  106736. /**
  106737. * Helps to define how blurry the reflections should appears in the material.
  106738. */
  106739. roughness: number;
  106740. /**
  106741. * In case of refraction, define the value of the index of refraction.
  106742. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106743. */
  106744. indexOfRefraction: number;
  106745. /**
  106746. * Invert the refraction texture alongside the y axis.
  106747. * It can be useful with procedural textures or probe for instance.
  106748. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106749. */
  106750. invertRefractionY: boolean;
  106751. /**
  106752. * Defines the alpha limits in alpha test mode.
  106753. */
  106754. alphaCutOff: number;
  106755. private _useLightmapAsShadowmap;
  106756. /**
  106757. * In case of light mapping, define whether the map contains light or shadow informations.
  106758. */
  106759. useLightmapAsShadowmap: boolean;
  106760. private _diffuseFresnelParameters;
  106761. /**
  106762. * Define the diffuse fresnel parameters of the material.
  106763. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106764. */
  106765. diffuseFresnelParameters: FresnelParameters;
  106766. private _opacityFresnelParameters;
  106767. /**
  106768. * Define the opacity fresnel parameters of the material.
  106769. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106770. */
  106771. opacityFresnelParameters: FresnelParameters;
  106772. private _reflectionFresnelParameters;
  106773. /**
  106774. * Define the reflection fresnel parameters of the material.
  106775. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106776. */
  106777. reflectionFresnelParameters: FresnelParameters;
  106778. private _refractionFresnelParameters;
  106779. /**
  106780. * Define the refraction fresnel parameters of the material.
  106781. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106782. */
  106783. refractionFresnelParameters: FresnelParameters;
  106784. private _emissiveFresnelParameters;
  106785. /**
  106786. * Define the emissive fresnel parameters of the material.
  106787. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106788. */
  106789. emissiveFresnelParameters: FresnelParameters;
  106790. private _useReflectionFresnelFromSpecular;
  106791. /**
  106792. * If true automatically deducts the fresnels values from the material specularity.
  106793. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106794. */
  106795. useReflectionFresnelFromSpecular: boolean;
  106796. private _useGlossinessFromSpecularMapAlpha;
  106797. /**
  106798. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  106799. */
  106800. useGlossinessFromSpecularMapAlpha: boolean;
  106801. private _maxSimultaneousLights;
  106802. /**
  106803. * Defines the maximum number of lights that can be used in the material
  106804. */
  106805. maxSimultaneousLights: number;
  106806. private _invertNormalMapX;
  106807. /**
  106808. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  106809. */
  106810. invertNormalMapX: boolean;
  106811. private _invertNormalMapY;
  106812. /**
  106813. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  106814. */
  106815. invertNormalMapY: boolean;
  106816. private _twoSidedLighting;
  106817. /**
  106818. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106819. */
  106820. twoSidedLighting: boolean;
  106821. /**
  106822. * Default configuration related to image processing available in the standard Material.
  106823. */
  106824. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106825. /**
  106826. * Gets the image processing configuration used either in this material.
  106827. */
  106828. /**
  106829. * Sets the Default image processing configuration used either in the this material.
  106830. *
  106831. * If sets to null, the scene one is in use.
  106832. */
  106833. imageProcessingConfiguration: ImageProcessingConfiguration;
  106834. /**
  106835. * Keep track of the image processing observer to allow dispose and replace.
  106836. */
  106837. private _imageProcessingObserver;
  106838. /**
  106839. * Attaches a new image processing configuration to the Standard Material.
  106840. * @param configuration
  106841. */
  106842. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106843. /**
  106844. * Gets wether the color curves effect is enabled.
  106845. */
  106846. /**
  106847. * Sets wether the color curves effect is enabled.
  106848. */
  106849. cameraColorCurvesEnabled: boolean;
  106850. /**
  106851. * Gets wether the color grading effect is enabled.
  106852. */
  106853. /**
  106854. * Gets wether the color grading effect is enabled.
  106855. */
  106856. cameraColorGradingEnabled: boolean;
  106857. /**
  106858. * Gets wether tonemapping is enabled or not.
  106859. */
  106860. /**
  106861. * Sets wether tonemapping is enabled or not
  106862. */
  106863. cameraToneMappingEnabled: boolean;
  106864. /**
  106865. * The camera exposure used on this material.
  106866. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106867. * This corresponds to a photographic exposure.
  106868. */
  106869. /**
  106870. * The camera exposure used on this material.
  106871. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106872. * This corresponds to a photographic exposure.
  106873. */
  106874. cameraExposure: number;
  106875. /**
  106876. * Gets The camera contrast used on this material.
  106877. */
  106878. /**
  106879. * Sets The camera contrast used on this material.
  106880. */
  106881. cameraContrast: number;
  106882. /**
  106883. * Gets the Color Grading 2D Lookup Texture.
  106884. */
  106885. /**
  106886. * Sets the Color Grading 2D Lookup Texture.
  106887. */
  106888. cameraColorGradingTexture: Nullable<BaseTexture>;
  106889. /**
  106890. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106891. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106892. * 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;
  106893. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106894. */
  106895. /**
  106896. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106897. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106898. * 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;
  106899. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106900. */
  106901. cameraColorCurves: Nullable<ColorCurves>;
  106902. /**
  106903. * Custom callback helping to override the default shader used in the material.
  106904. */
  106905. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  106906. protected _renderTargets: SmartArray<RenderTargetTexture>;
  106907. protected _worldViewProjectionMatrix: Matrix;
  106908. protected _globalAmbientColor: Color3;
  106909. protected _useLogarithmicDepth: boolean;
  106910. protected _rebuildInParallel: boolean;
  106911. /**
  106912. * Instantiates a new standard material.
  106913. * This is the default material used in Babylon. It is the best trade off between quality
  106914. * and performances.
  106915. * @see http://doc.babylonjs.com/babylon101/materials
  106916. * @param name Define the name of the material in the scene
  106917. * @param scene Define the scene the material belong to
  106918. */
  106919. constructor(name: string, scene: Scene);
  106920. /**
  106921. * Gets a boolean indicating that current material needs to register RTT
  106922. */
  106923. readonly hasRenderTargetTextures: boolean;
  106924. /**
  106925. * Gets the current class name of the material e.g. "StandardMaterial"
  106926. * Mainly use in serialization.
  106927. * @returns the class name
  106928. */
  106929. getClassName(): string;
  106930. /**
  106931. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  106932. * You can try switching to logarithmic depth.
  106933. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  106934. */
  106935. useLogarithmicDepth: boolean;
  106936. /**
  106937. * Specifies if the material will require alpha blending
  106938. * @returns a boolean specifying if alpha blending is needed
  106939. */
  106940. needAlphaBlending(): boolean;
  106941. /**
  106942. * Specifies if this material should be rendered in alpha test mode
  106943. * @returns a boolean specifying if an alpha test is needed.
  106944. */
  106945. needAlphaTesting(): boolean;
  106946. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  106947. /**
  106948. * Get the texture used for alpha test purpose.
  106949. * @returns the diffuse texture in case of the standard material.
  106950. */
  106951. getAlphaTestTexture(): Nullable<BaseTexture>;
  106952. /**
  106953. * Get if the submesh is ready to be used and all its information available.
  106954. * Child classes can use it to update shaders
  106955. * @param mesh defines the mesh to check
  106956. * @param subMesh defines which submesh to check
  106957. * @param useInstances specifies that instances should be used
  106958. * @returns a boolean indicating that the submesh is ready or not
  106959. */
  106960. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106961. /**
  106962. * Builds the material UBO layouts.
  106963. * Used internally during the effect preparation.
  106964. */
  106965. buildUniformLayout(): void;
  106966. /**
  106967. * Unbinds the material from the mesh
  106968. */
  106969. unbind(): void;
  106970. /**
  106971. * Binds the submesh to this material by preparing the effect and shader to draw
  106972. * @param world defines the world transformation matrix
  106973. * @param mesh defines the mesh containing the submesh
  106974. * @param subMesh defines the submesh to bind the material to
  106975. */
  106976. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106977. /**
  106978. * Get the list of animatables in the material.
  106979. * @returns the list of animatables object used in the material
  106980. */
  106981. getAnimatables(): IAnimatable[];
  106982. /**
  106983. * Gets the active textures from the material
  106984. * @returns an array of textures
  106985. */
  106986. getActiveTextures(): BaseTexture[];
  106987. /**
  106988. * Specifies if the material uses a texture
  106989. * @param texture defines the texture to check against the material
  106990. * @returns a boolean specifying if the material uses the texture
  106991. */
  106992. hasTexture(texture: BaseTexture): boolean;
  106993. /**
  106994. * Disposes the material
  106995. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  106996. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  106997. */
  106998. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106999. /**
  107000. * Makes a duplicate of the material, and gives it a new name
  107001. * @param name defines the new name for the duplicated material
  107002. * @returns the cloned material
  107003. */
  107004. clone(name: string): StandardMaterial;
  107005. /**
  107006. * Serializes this material in a JSON representation
  107007. * @returns the serialized material object
  107008. */
  107009. serialize(): any;
  107010. /**
  107011. * Creates a standard material from parsed material data
  107012. * @param source defines the JSON representation of the material
  107013. * @param scene defines the hosting scene
  107014. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107015. * @returns a new standard material
  107016. */
  107017. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107018. /**
  107019. * Are diffuse textures enabled in the application.
  107020. */
  107021. static DiffuseTextureEnabled: boolean;
  107022. /**
  107023. * Are ambient textures enabled in the application.
  107024. */
  107025. static AmbientTextureEnabled: boolean;
  107026. /**
  107027. * Are opacity textures enabled in the application.
  107028. */
  107029. static OpacityTextureEnabled: boolean;
  107030. /**
  107031. * Are reflection textures enabled in the application.
  107032. */
  107033. static ReflectionTextureEnabled: boolean;
  107034. /**
  107035. * Are emissive textures enabled in the application.
  107036. */
  107037. static EmissiveTextureEnabled: boolean;
  107038. /**
  107039. * Are specular textures enabled in the application.
  107040. */
  107041. static SpecularTextureEnabled: boolean;
  107042. /**
  107043. * Are bump textures enabled in the application.
  107044. */
  107045. static BumpTextureEnabled: boolean;
  107046. /**
  107047. * Are lightmap textures enabled in the application.
  107048. */
  107049. static LightmapTextureEnabled: boolean;
  107050. /**
  107051. * Are refraction textures enabled in the application.
  107052. */
  107053. static RefractionTextureEnabled: boolean;
  107054. /**
  107055. * Are color grading textures enabled in the application.
  107056. */
  107057. static ColorGradingTextureEnabled: boolean;
  107058. /**
  107059. * Are fresnels enabled in the application.
  107060. */
  107061. static FresnelEnabled: boolean;
  107062. }
  107063. }
  107064. declare module BABYLON {
  107065. /** @hidden */
  107066. export var imageProcessingPixelShader: {
  107067. name: string;
  107068. shader: string;
  107069. };
  107070. }
  107071. declare module BABYLON {
  107072. /**
  107073. * ImageProcessingPostProcess
  107074. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  107075. */
  107076. export class ImageProcessingPostProcess extends PostProcess {
  107077. /**
  107078. * Default configuration related to image processing available in the PBR Material.
  107079. */
  107080. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107081. /**
  107082. * Gets the image processing configuration used either in this material.
  107083. */
  107084. /**
  107085. * Sets the Default image processing configuration used either in the this material.
  107086. *
  107087. * If sets to null, the scene one is in use.
  107088. */
  107089. imageProcessingConfiguration: ImageProcessingConfiguration;
  107090. /**
  107091. * Keep track of the image processing observer to allow dispose and replace.
  107092. */
  107093. private _imageProcessingObserver;
  107094. /**
  107095. * Attaches a new image processing configuration to the PBR Material.
  107096. * @param configuration
  107097. */
  107098. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  107099. /**
  107100. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107101. */
  107102. /**
  107103. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107104. */
  107105. colorCurves: Nullable<ColorCurves>;
  107106. /**
  107107. * Gets wether the color curves effect is enabled.
  107108. */
  107109. /**
  107110. * Sets wether the color curves effect is enabled.
  107111. */
  107112. colorCurvesEnabled: boolean;
  107113. /**
  107114. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107115. */
  107116. /**
  107117. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107118. */
  107119. colorGradingTexture: Nullable<BaseTexture>;
  107120. /**
  107121. * Gets wether the color grading effect is enabled.
  107122. */
  107123. /**
  107124. * Gets wether the color grading effect is enabled.
  107125. */
  107126. colorGradingEnabled: boolean;
  107127. /**
  107128. * Gets exposure used in the effect.
  107129. */
  107130. /**
  107131. * Sets exposure used in the effect.
  107132. */
  107133. exposure: number;
  107134. /**
  107135. * Gets wether tonemapping is enabled or not.
  107136. */
  107137. /**
  107138. * Sets wether tonemapping is enabled or not
  107139. */
  107140. toneMappingEnabled: boolean;
  107141. /**
  107142. * Gets the type of tone mapping effect.
  107143. */
  107144. /**
  107145. * Sets the type of tone mapping effect.
  107146. */
  107147. toneMappingType: number;
  107148. /**
  107149. * Gets contrast used in the effect.
  107150. */
  107151. /**
  107152. * Sets contrast used in the effect.
  107153. */
  107154. contrast: number;
  107155. /**
  107156. * Gets Vignette stretch size.
  107157. */
  107158. /**
  107159. * Sets Vignette stretch size.
  107160. */
  107161. vignetteStretch: number;
  107162. /**
  107163. * Gets Vignette centre X Offset.
  107164. */
  107165. /**
  107166. * Sets Vignette centre X Offset.
  107167. */
  107168. vignetteCentreX: number;
  107169. /**
  107170. * Gets Vignette centre Y Offset.
  107171. */
  107172. /**
  107173. * Sets Vignette centre Y Offset.
  107174. */
  107175. vignetteCentreY: number;
  107176. /**
  107177. * Gets Vignette weight or intensity of the vignette effect.
  107178. */
  107179. /**
  107180. * Sets Vignette weight or intensity of the vignette effect.
  107181. */
  107182. vignetteWeight: number;
  107183. /**
  107184. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107185. * if vignetteEnabled is set to true.
  107186. */
  107187. /**
  107188. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107189. * if vignetteEnabled is set to true.
  107190. */
  107191. vignetteColor: Color4;
  107192. /**
  107193. * Gets Camera field of view used by the Vignette effect.
  107194. */
  107195. /**
  107196. * Sets Camera field of view used by the Vignette effect.
  107197. */
  107198. vignetteCameraFov: number;
  107199. /**
  107200. * Gets the vignette blend mode allowing different kind of effect.
  107201. */
  107202. /**
  107203. * Sets the vignette blend mode allowing different kind of effect.
  107204. */
  107205. vignetteBlendMode: number;
  107206. /**
  107207. * Gets wether the vignette effect is enabled.
  107208. */
  107209. /**
  107210. * Sets wether the vignette effect is enabled.
  107211. */
  107212. vignetteEnabled: boolean;
  107213. private _fromLinearSpace;
  107214. /**
  107215. * Gets wether the input of the processing is in Gamma or Linear Space.
  107216. */
  107217. /**
  107218. * Sets wether the input of the processing is in Gamma or Linear Space.
  107219. */
  107220. fromLinearSpace: boolean;
  107221. /**
  107222. * Defines cache preventing GC.
  107223. */
  107224. private _defines;
  107225. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  107226. /**
  107227. * "ImageProcessingPostProcess"
  107228. * @returns "ImageProcessingPostProcess"
  107229. */
  107230. getClassName(): string;
  107231. protected _updateParameters(): void;
  107232. dispose(camera?: Camera): void;
  107233. }
  107234. }
  107235. declare module BABYLON {
  107236. /**
  107237. * Class containing static functions to help procedurally build meshes
  107238. */
  107239. export class GroundBuilder {
  107240. /**
  107241. * Creates a ground mesh
  107242. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  107243. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  107244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107245. * @param name defines the name of the mesh
  107246. * @param options defines the options used to create the mesh
  107247. * @param scene defines the hosting scene
  107248. * @returns the ground mesh
  107249. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  107250. */
  107251. static CreateGround(name: string, options: {
  107252. width?: number;
  107253. height?: number;
  107254. subdivisions?: number;
  107255. subdivisionsX?: number;
  107256. subdivisionsY?: number;
  107257. updatable?: boolean;
  107258. }, scene: any): Mesh;
  107259. /**
  107260. * Creates a tiled ground mesh
  107261. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  107262. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  107263. * * 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
  107264. * * 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
  107265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107266. * @param name defines the name of the mesh
  107267. * @param options defines the options used to create the mesh
  107268. * @param scene defines the hosting scene
  107269. * @returns the tiled ground mesh
  107270. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  107271. */
  107272. static CreateTiledGround(name: string, options: {
  107273. xmin: number;
  107274. zmin: number;
  107275. xmax: number;
  107276. zmax: number;
  107277. subdivisions?: {
  107278. w: number;
  107279. h: number;
  107280. };
  107281. precision?: {
  107282. w: number;
  107283. h: number;
  107284. };
  107285. updatable?: boolean;
  107286. }, scene?: Nullable<Scene>): Mesh;
  107287. /**
  107288. * Creates a ground mesh from a height map
  107289. * * The parameter `url` sets the URL of the height map image resource.
  107290. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  107291. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  107292. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  107293. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  107294. * * 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.
  107295. * * 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).
  107296. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107298. * @param name defines the name of the mesh
  107299. * @param url defines the url to the height map
  107300. * @param options defines the options used to create the mesh
  107301. * @param scene defines the hosting scene
  107302. * @returns the ground mesh
  107303. * @see https://doc.babylonjs.com/babylon101/height_map
  107304. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  107305. */
  107306. static CreateGroundFromHeightMap(name: string, url: string, options: {
  107307. width?: number;
  107308. height?: number;
  107309. subdivisions?: number;
  107310. minHeight?: number;
  107311. maxHeight?: number;
  107312. colorFilter?: Color3;
  107313. alphaFilter?: number;
  107314. updatable?: boolean;
  107315. onReady?: (mesh: GroundMesh) => void;
  107316. }, scene?: Nullable<Scene>): GroundMesh;
  107317. }
  107318. }
  107319. declare module BABYLON {
  107320. /**
  107321. * Class containing static functions to help procedurally build meshes
  107322. */
  107323. export class TorusBuilder {
  107324. /**
  107325. * Creates a torus mesh
  107326. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  107327. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  107328. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  107329. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107330. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107332. * @param name defines the name of the mesh
  107333. * @param options defines the options used to create the mesh
  107334. * @param scene defines the hosting scene
  107335. * @returns the torus mesh
  107336. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  107337. */
  107338. static CreateTorus(name: string, options: {
  107339. diameter?: number;
  107340. thickness?: number;
  107341. tessellation?: number;
  107342. updatable?: boolean;
  107343. sideOrientation?: number;
  107344. frontUVs?: Vector4;
  107345. backUVs?: Vector4;
  107346. }, scene: any): Mesh;
  107347. }
  107348. }
  107349. declare module BABYLON {
  107350. /**
  107351. * Class containing static functions to help procedurally build meshes
  107352. */
  107353. export class CylinderBuilder {
  107354. /**
  107355. * Creates a cylinder or a cone mesh
  107356. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  107357. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  107358. * * 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.
  107359. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  107360. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  107361. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  107362. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  107363. * * 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).
  107364. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  107365. * * 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).
  107366. * * 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
  107367. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  107368. * * 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
  107369. * * 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.
  107370. * * If `enclose` is false, a ring surface is one element.
  107371. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  107372. * * 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
  107373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107374. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107376. * @param name defines the name of the mesh
  107377. * @param options defines the options used to create the mesh
  107378. * @param scene defines the hosting scene
  107379. * @returns the cylinder mesh
  107380. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  107381. */
  107382. static CreateCylinder(name: string, options: {
  107383. height?: number;
  107384. diameterTop?: number;
  107385. diameterBottom?: number;
  107386. diameter?: number;
  107387. tessellation?: number;
  107388. subdivisions?: number;
  107389. arc?: number;
  107390. faceColors?: Color4[];
  107391. faceUV?: Vector4[];
  107392. updatable?: boolean;
  107393. hasRings?: boolean;
  107394. enclose?: boolean;
  107395. cap?: number;
  107396. sideOrientation?: number;
  107397. frontUVs?: Vector4;
  107398. backUVs?: Vector4;
  107399. }, scene: any): Mesh;
  107400. }
  107401. }
  107402. declare module BABYLON {
  107403. /**
  107404. * Options to modify the vr teleportation behavior.
  107405. */
  107406. export interface VRTeleportationOptions {
  107407. /**
  107408. * The name of the mesh which should be used as the teleportation floor. (default: null)
  107409. */
  107410. floorMeshName?: string;
  107411. /**
  107412. * A list of meshes to be used as the teleportation floor. (default: empty)
  107413. */
  107414. floorMeshes?: Mesh[];
  107415. }
  107416. /**
  107417. * Options to modify the vr experience helper's behavior.
  107418. */
  107419. export interface VRExperienceHelperOptions extends WebVROptions {
  107420. /**
  107421. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  107422. */
  107423. createDeviceOrientationCamera?: boolean;
  107424. /**
  107425. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  107426. */
  107427. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  107428. /**
  107429. * Uses the main button on the controller to toggle the laser casted. (default: true)
  107430. */
  107431. laserToggle?: boolean;
  107432. /**
  107433. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  107434. */
  107435. floorMeshes?: Mesh[];
  107436. /**
  107437. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  107438. */
  107439. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  107440. }
  107441. /**
  107442. * Event containing information after VR has been entered
  107443. */
  107444. export class OnAfterEnteringVRObservableEvent {
  107445. /**
  107446. * If entering vr was successful
  107447. */
  107448. success: boolean;
  107449. }
  107450. /**
  107451. * Helps to quickly add VR support to an existing scene.
  107452. * See http://doc.babylonjs.com/how_to/webvr_helper
  107453. */
  107454. export class VRExperienceHelper {
  107455. /** Options to modify the vr experience helper's behavior. */
  107456. webVROptions: VRExperienceHelperOptions;
  107457. private _scene;
  107458. private _position;
  107459. private _btnVR;
  107460. private _btnVRDisplayed;
  107461. private _webVRsupported;
  107462. private _webVRready;
  107463. private _webVRrequesting;
  107464. private _webVRpresenting;
  107465. private _hasEnteredVR;
  107466. private _fullscreenVRpresenting;
  107467. private _canvas;
  107468. private _webVRCamera;
  107469. private _vrDeviceOrientationCamera;
  107470. private _deviceOrientationCamera;
  107471. private _existingCamera;
  107472. private _onKeyDown;
  107473. private _onVrDisplayPresentChange;
  107474. private _onVRDisplayChanged;
  107475. private _onVRRequestPresentStart;
  107476. private _onVRRequestPresentComplete;
  107477. /**
  107478. * 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)
  107479. */
  107480. enableGazeEvenWhenNoPointerLock: boolean;
  107481. /**
  107482. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  107483. */
  107484. exitVROnDoubleTap: boolean;
  107485. /**
  107486. * Observable raised right before entering VR.
  107487. */
  107488. onEnteringVRObservable: Observable<VRExperienceHelper>;
  107489. /**
  107490. * Observable raised when entering VR has completed.
  107491. */
  107492. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  107493. /**
  107494. * Observable raised when exiting VR.
  107495. */
  107496. onExitingVRObservable: Observable<VRExperienceHelper>;
  107497. /**
  107498. * Observable raised when controller mesh is loaded.
  107499. */
  107500. onControllerMeshLoadedObservable: Observable<WebVRController>;
  107501. /** Return this.onEnteringVRObservable
  107502. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  107503. */
  107504. readonly onEnteringVR: Observable<VRExperienceHelper>;
  107505. /** Return this.onExitingVRObservable
  107506. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  107507. */
  107508. readonly onExitingVR: Observable<VRExperienceHelper>;
  107509. /** Return this.onControllerMeshLoadedObservable
  107510. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  107511. */
  107512. readonly onControllerMeshLoaded: Observable<WebVRController>;
  107513. private _rayLength;
  107514. private _useCustomVRButton;
  107515. private _teleportationRequested;
  107516. private _teleportActive;
  107517. private _floorMeshName;
  107518. private _floorMeshesCollection;
  107519. private _rotationAllowed;
  107520. private _teleportBackwardsVector;
  107521. private _teleportationTarget;
  107522. private _isDefaultTeleportationTarget;
  107523. private _postProcessMove;
  107524. private _teleportationFillColor;
  107525. private _teleportationBorderColor;
  107526. private _rotationAngle;
  107527. private _haloCenter;
  107528. private _cameraGazer;
  107529. private _padSensibilityUp;
  107530. private _padSensibilityDown;
  107531. private _leftController;
  107532. private _rightController;
  107533. /**
  107534. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  107535. */
  107536. onNewMeshSelected: Observable<AbstractMesh>;
  107537. /**
  107538. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  107539. * This observable will provide the mesh and the controller used to select the mesh
  107540. */
  107541. onMeshSelectedWithController: Observable<{
  107542. mesh: AbstractMesh;
  107543. controller: WebVRController;
  107544. }>;
  107545. /**
  107546. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  107547. */
  107548. onNewMeshPicked: Observable<PickingInfo>;
  107549. private _circleEase;
  107550. /**
  107551. * Observable raised before camera teleportation
  107552. */
  107553. onBeforeCameraTeleport: Observable<Vector3>;
  107554. /**
  107555. * Observable raised after camera teleportation
  107556. */
  107557. onAfterCameraTeleport: Observable<Vector3>;
  107558. /**
  107559. * Observable raised when current selected mesh gets unselected
  107560. */
  107561. onSelectedMeshUnselected: Observable<AbstractMesh>;
  107562. private _raySelectionPredicate;
  107563. /**
  107564. * To be optionaly changed by user to define custom ray selection
  107565. */
  107566. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  107567. /**
  107568. * To be optionaly changed by user to define custom selection logic (after ray selection)
  107569. */
  107570. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107571. /**
  107572. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  107573. */
  107574. teleportationEnabled: boolean;
  107575. private _defaultHeight;
  107576. private _teleportationInitialized;
  107577. private _interactionsEnabled;
  107578. private _interactionsRequested;
  107579. private _displayGaze;
  107580. private _displayLaserPointer;
  107581. /**
  107582. * The mesh used to display where the user is going to teleport.
  107583. */
  107584. /**
  107585. * Sets the mesh to be used to display where the user is going to teleport.
  107586. */
  107587. teleportationTarget: Mesh;
  107588. /**
  107589. * 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
  107590. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  107591. * See http://doc.babylonjs.com/resources/baking_transformations
  107592. */
  107593. gazeTrackerMesh: Mesh;
  107594. /**
  107595. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  107596. */
  107597. updateGazeTrackerScale: boolean;
  107598. /**
  107599. * If the gaze trackers color should be updated when selecting meshes
  107600. */
  107601. updateGazeTrackerColor: boolean;
  107602. /**
  107603. * If the controller laser color should be updated when selecting meshes
  107604. */
  107605. updateControllerLaserColor: boolean;
  107606. /**
  107607. * The gaze tracking mesh corresponding to the left controller
  107608. */
  107609. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  107610. /**
  107611. * The gaze tracking mesh corresponding to the right controller
  107612. */
  107613. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  107614. /**
  107615. * If the ray of the gaze should be displayed.
  107616. */
  107617. /**
  107618. * Sets if the ray of the gaze should be displayed.
  107619. */
  107620. displayGaze: boolean;
  107621. /**
  107622. * If the ray of the LaserPointer should be displayed.
  107623. */
  107624. /**
  107625. * Sets if the ray of the LaserPointer should be displayed.
  107626. */
  107627. displayLaserPointer: boolean;
  107628. /**
  107629. * The deviceOrientationCamera used as the camera when not in VR.
  107630. */
  107631. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  107632. /**
  107633. * Based on the current WebVR support, returns the current VR camera used.
  107634. */
  107635. readonly currentVRCamera: Nullable<Camera>;
  107636. /**
  107637. * The webVRCamera which is used when in VR.
  107638. */
  107639. readonly webVRCamera: WebVRFreeCamera;
  107640. /**
  107641. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  107642. */
  107643. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  107644. /**
  107645. * The html button that is used to trigger entering into VR.
  107646. */
  107647. readonly vrButton: Nullable<HTMLButtonElement>;
  107648. private readonly _teleportationRequestInitiated;
  107649. /**
  107650. * Defines wether or not Pointer lock should be requested when switching to
  107651. * full screen.
  107652. */
  107653. requestPointerLockOnFullScreen: boolean;
  107654. /**
  107655. * Instantiates a VRExperienceHelper.
  107656. * Helps to quickly add VR support to an existing scene.
  107657. * @param scene The scene the VRExperienceHelper belongs to.
  107658. * @param webVROptions Options to modify the vr experience helper's behavior.
  107659. */
  107660. constructor(scene: Scene,
  107661. /** Options to modify the vr experience helper's behavior. */
  107662. webVROptions?: VRExperienceHelperOptions);
  107663. private _onDefaultMeshLoaded;
  107664. private _onResize;
  107665. private _onFullscreenChange;
  107666. /**
  107667. * Gets a value indicating if we are currently in VR mode.
  107668. */
  107669. readonly isInVRMode: boolean;
  107670. private onVrDisplayPresentChange;
  107671. private onVRDisplayChanged;
  107672. private moveButtonToBottomRight;
  107673. private displayVRButton;
  107674. private updateButtonVisibility;
  107675. private _cachedAngularSensibility;
  107676. /**
  107677. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  107678. * Otherwise, will use the fullscreen API.
  107679. */
  107680. enterVR(): void;
  107681. /**
  107682. * Attempt to exit VR, or fullscreen.
  107683. */
  107684. exitVR(): void;
  107685. /**
  107686. * The position of the vr experience helper.
  107687. */
  107688. /**
  107689. * Sets the position of the vr experience helper.
  107690. */
  107691. position: Vector3;
  107692. /**
  107693. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  107694. */
  107695. enableInteractions(): void;
  107696. private readonly _noControllerIsActive;
  107697. private beforeRender;
  107698. private _isTeleportationFloor;
  107699. /**
  107700. * Adds a floor mesh to be used for teleportation.
  107701. * @param floorMesh the mesh to be used for teleportation.
  107702. */
  107703. addFloorMesh(floorMesh: Mesh): void;
  107704. /**
  107705. * Removes a floor mesh from being used for teleportation.
  107706. * @param floorMesh the mesh to be removed.
  107707. */
  107708. removeFloorMesh(floorMesh: Mesh): void;
  107709. /**
  107710. * Enables interactions and teleportation using the VR controllers and gaze.
  107711. * @param vrTeleportationOptions options to modify teleportation behavior.
  107712. */
  107713. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  107714. private _onNewGamepadConnected;
  107715. private _tryEnableInteractionOnController;
  107716. private _onNewGamepadDisconnected;
  107717. private _enableInteractionOnController;
  107718. private _checkTeleportWithRay;
  107719. private _checkRotate;
  107720. private _checkTeleportBackwards;
  107721. private _enableTeleportationOnController;
  107722. private _createTeleportationCircles;
  107723. private _displayTeleportationTarget;
  107724. private _hideTeleportationTarget;
  107725. private _rotateCamera;
  107726. private _moveTeleportationSelectorTo;
  107727. private _workingVector;
  107728. private _workingQuaternion;
  107729. private _workingMatrix;
  107730. /**
  107731. * Teleports the users feet to the desired location
  107732. * @param location The location where the user's feet should be placed
  107733. */
  107734. teleportCamera(location: Vector3): void;
  107735. private _convertNormalToDirectionOfRay;
  107736. private _castRayAndSelectObject;
  107737. private _notifySelectedMeshUnselected;
  107738. /**
  107739. * Sets the color of the laser ray from the vr controllers.
  107740. * @param color new color for the ray.
  107741. */
  107742. changeLaserColor(color: Color3): void;
  107743. /**
  107744. * Sets the color of the ray from the vr headsets gaze.
  107745. * @param color new color for the ray.
  107746. */
  107747. changeGazeColor(color: Color3): void;
  107748. /**
  107749. * Exits VR and disposes of the vr experience helper
  107750. */
  107751. dispose(): void;
  107752. /**
  107753. * Gets the name of the VRExperienceHelper class
  107754. * @returns "VRExperienceHelper"
  107755. */
  107756. getClassName(): string;
  107757. }
  107758. }
  107759. declare module BABYLON {
  107760. /**
  107761. * Manages an XRSession to work with Babylon's engine
  107762. * @see https://doc.babylonjs.com/how_to/webxr
  107763. */
  107764. export class WebXRSessionManager implements IDisposable {
  107765. private scene;
  107766. /**
  107767. * Fires every time a new xrFrame arrives which can be used to update the camera
  107768. */
  107769. onXRFrameObservable: Observable<any>;
  107770. /**
  107771. * Fires when the xr session is ended either by the device or manually done
  107772. */
  107773. onXRSessionEnded: Observable<any>;
  107774. /**
  107775. * Underlying xr session
  107776. */
  107777. session: XRSession;
  107778. /**
  107779. * Type of reference space used when creating the session
  107780. */
  107781. referenceSpace: XRReferenceSpace;
  107782. /** @hidden */
  107783. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  107784. /**
  107785. * Current XR frame
  107786. */
  107787. currentFrame: Nullable<XRFrame>;
  107788. private _xrNavigator;
  107789. private baseLayer;
  107790. /**
  107791. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  107792. * @param scene The scene which the session should be created for
  107793. */
  107794. constructor(scene: Scene);
  107795. /**
  107796. * Initializes the manager
  107797. * After initialization enterXR can be called to start an XR session
  107798. * @returns Promise which resolves after it is initialized
  107799. */
  107800. initializeAsync(): Promise<void>;
  107801. /**
  107802. * Initializes an xr session
  107803. * @param xrSessionMode mode to initialize
  107804. * @returns a promise which will resolve once the session has been initialized
  107805. */
  107806. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  107807. /**
  107808. * Sets the reference space on the xr session
  107809. * @param referenceSpace space to set
  107810. * @returns a promise that will resolve once the reference space has been set
  107811. */
  107812. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  107813. /**
  107814. * Updates the render state of the session
  107815. * @param state state to set
  107816. * @returns a promise that resolves once the render state has been updated
  107817. */
  107818. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  107819. /**
  107820. * Starts rendering to the xr layer
  107821. * @returns a promise that will resolve once rendering has started
  107822. */
  107823. startRenderingToXRAsync(): Promise<void>;
  107824. /**
  107825. * Stops the xrSession and restores the renderloop
  107826. * @returns Promise which resolves after it exits XR
  107827. */
  107828. exitXRAsync(): Promise<unknown>;
  107829. /**
  107830. * Checks if a session would be supported for the creation options specified
  107831. * @param sessionMode session mode to check if supported eg. immersive-vr
  107832. * @returns true if supported
  107833. */
  107834. supportsSessionAsync(sessionMode: XRSessionMode): any;
  107835. /**
  107836. * @hidden
  107837. * Converts the render layer of xrSession to a render target
  107838. * @param session session to create render target for
  107839. * @param scene scene the new render target should be created for
  107840. */
  107841. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  107842. /**
  107843. * Disposes of the session manager
  107844. */
  107845. dispose(): void;
  107846. }
  107847. }
  107848. declare module BABYLON {
  107849. /**
  107850. * WebXR Camera which holds the views for the xrSession
  107851. * @see https://doc.babylonjs.com/how_to/webxr
  107852. */
  107853. export class WebXRCamera extends FreeCamera {
  107854. private static _TmpMatrix;
  107855. /**
  107856. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  107857. * @param name the name of the camera
  107858. * @param scene the scene to add the camera to
  107859. */
  107860. constructor(name: string, scene: Scene);
  107861. private _updateNumberOfRigCameras;
  107862. /** @hidden */
  107863. _updateForDualEyeDebugging(pupilDistance?: number): void;
  107864. /**
  107865. * Updates the cameras position from the current pose information of the XR session
  107866. * @param xrSessionManager the session containing pose information
  107867. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  107868. */
  107869. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  107870. }
  107871. }
  107872. declare module BABYLON {
  107873. /**
  107874. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  107875. */
  107876. export class WebXRManagedOutputCanvas implements IDisposable {
  107877. private helper;
  107878. private _canvas;
  107879. /**
  107880. * xrpresent context of the canvas which can be used to display/mirror xr content
  107881. */
  107882. canvasContext: WebGLRenderingContext;
  107883. /**
  107884. * xr layer for the canvas
  107885. */
  107886. xrLayer: Nullable<XRWebGLLayer>;
  107887. /**
  107888. * Initializes the xr layer for the session
  107889. * @param xrSession xr session
  107890. * @returns a promise that will resolve once the XR Layer has been created
  107891. */
  107892. initializeXRLayerAsync(xrSession: any): any;
  107893. /**
  107894. * Initializes the canvas to be added/removed upon entering/exiting xr
  107895. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  107896. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  107897. */
  107898. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  107899. /**
  107900. * Disposes of the object
  107901. */
  107902. dispose(): void;
  107903. private _setManagedOutputCanvas;
  107904. private _addCanvas;
  107905. private _removeCanvas;
  107906. }
  107907. }
  107908. declare module BABYLON {
  107909. /**
  107910. * States of the webXR experience
  107911. */
  107912. export enum WebXRState {
  107913. /**
  107914. * Transitioning to being in XR mode
  107915. */
  107916. ENTERING_XR = 0,
  107917. /**
  107918. * Transitioning to non XR mode
  107919. */
  107920. EXITING_XR = 1,
  107921. /**
  107922. * In XR mode and presenting
  107923. */
  107924. IN_XR = 2,
  107925. /**
  107926. * Not entered XR mode
  107927. */
  107928. NOT_IN_XR = 3
  107929. }
  107930. /**
  107931. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  107932. * @see https://doc.babylonjs.com/how_to/webxr
  107933. */
  107934. export class WebXRExperienceHelper implements IDisposable {
  107935. private scene;
  107936. /**
  107937. * 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
  107938. */
  107939. container: AbstractMesh;
  107940. /**
  107941. * Camera used to render xr content
  107942. */
  107943. camera: WebXRCamera;
  107944. /**
  107945. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  107946. */
  107947. state: WebXRState;
  107948. private _setState;
  107949. private static _TmpVector;
  107950. /**
  107951. * Fires when the state of the experience helper has changed
  107952. */
  107953. onStateChangedObservable: Observable<WebXRState>;
  107954. /** Session manager used to keep track of xr session */
  107955. sessionManager: WebXRSessionManager;
  107956. private _nonVRCamera;
  107957. private _originalSceneAutoClear;
  107958. private _supported;
  107959. /**
  107960. * Creates the experience helper
  107961. * @param scene the scene to attach the experience helper to
  107962. * @returns a promise for the experience helper
  107963. */
  107964. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  107965. /**
  107966. * Creates a WebXRExperienceHelper
  107967. * @param scene The scene the helper should be created in
  107968. */
  107969. private constructor();
  107970. /**
  107971. * Exits XR mode and returns the scene to its original state
  107972. * @returns promise that resolves after xr mode has exited
  107973. */
  107974. exitXRAsync(): Promise<unknown>;
  107975. /**
  107976. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  107977. * @param sessionCreationOptions options for the XR session
  107978. * @param referenceSpaceType frame of reference of the XR session
  107979. * @param outputCanvas the output canvas that will be used to enter XR mode
  107980. * @returns promise that resolves after xr mode has entered
  107981. */
  107982. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  107983. /**
  107984. * Updates the global position of the camera by moving the camera's container
  107985. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  107986. * @param position The desired global position of the camera
  107987. */
  107988. setPositionOfCameraUsingContainer(position: Vector3): void;
  107989. /**
  107990. * Rotates the xr camera by rotating the camera's container around the camera's position
  107991. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  107992. * @param rotation the desired quaternion rotation to apply to the camera
  107993. */
  107994. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  107995. /**
  107996. * Disposes of the experience helper
  107997. */
  107998. dispose(): void;
  107999. }
  108000. }
  108001. declare module BABYLON {
  108002. /**
  108003. * Button which can be used to enter a different mode of XR
  108004. */
  108005. export class WebXREnterExitUIButton {
  108006. /** button element */
  108007. element: HTMLElement;
  108008. /** XR initialization options for the button */
  108009. sessionMode: XRSessionMode;
  108010. /** Reference space type */
  108011. referenceSpaceType: XRReferenceSpaceType;
  108012. /**
  108013. * Creates a WebXREnterExitUIButton
  108014. * @param element button element
  108015. * @param sessionMode XR initialization session mode
  108016. * @param referenceSpaceType the type of reference space to be used
  108017. */
  108018. constructor(
  108019. /** button element */
  108020. element: HTMLElement,
  108021. /** XR initialization options for the button */
  108022. sessionMode: XRSessionMode,
  108023. /** Reference space type */
  108024. referenceSpaceType: XRReferenceSpaceType);
  108025. /**
  108026. * Overwritable function which can be used to update the button's visuals when the state changes
  108027. * @param activeButton the current active button in the UI
  108028. */
  108029. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  108030. }
  108031. /**
  108032. * Options to create the webXR UI
  108033. */
  108034. export class WebXREnterExitUIOptions {
  108035. /**
  108036. * Context to enter xr with
  108037. */
  108038. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  108039. /**
  108040. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  108041. */
  108042. customButtons?: Array<WebXREnterExitUIButton>;
  108043. }
  108044. /**
  108045. * UI to allow the user to enter/exit XR mode
  108046. */
  108047. export class WebXREnterExitUI implements IDisposable {
  108048. private scene;
  108049. private _overlay;
  108050. private _buttons;
  108051. private _activeButton;
  108052. /**
  108053. * Fired every time the active button is changed.
  108054. *
  108055. * When xr is entered via a button that launches xr that button will be the callback parameter
  108056. *
  108057. * When exiting xr the callback parameter will be null)
  108058. */
  108059. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  108060. /**
  108061. * Creates UI to allow the user to enter/exit XR mode
  108062. * @param scene the scene to add the ui to
  108063. * @param helper the xr experience helper to enter/exit xr with
  108064. * @param options options to configure the UI
  108065. * @returns the created ui
  108066. */
  108067. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  108068. private constructor();
  108069. private _updateButtons;
  108070. /**
  108071. * Disposes of the object
  108072. */
  108073. dispose(): void;
  108074. }
  108075. }
  108076. declare module BABYLON {
  108077. /**
  108078. * Represents an XR input
  108079. */
  108080. export class WebXRController {
  108081. private scene;
  108082. /** The underlying input source for the controller */
  108083. inputSource: XRInputSource;
  108084. private parentContainer;
  108085. /**
  108086. * 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
  108087. */
  108088. grip?: AbstractMesh;
  108089. /**
  108090. * Pointer which can be used to select objects or attach a visible laser to
  108091. */
  108092. pointer: AbstractMesh;
  108093. /**
  108094. * Event that fires when the controller is removed/disposed
  108095. */
  108096. onDisposeObservable: Observable<{}>;
  108097. private _tmpMatrix;
  108098. private _tmpQuaternion;
  108099. private _tmpVector;
  108100. /**
  108101. * Creates the controller
  108102. * @see https://doc.babylonjs.com/how_to/webxr
  108103. * @param scene the scene which the controller should be associated to
  108104. * @param inputSource the underlying input source for the controller
  108105. * @param parentContainer parent that the controller meshes should be children of
  108106. */
  108107. constructor(scene: Scene,
  108108. /** The underlying input source for the controller */
  108109. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  108110. /**
  108111. * Updates the controller pose based on the given XRFrame
  108112. * @param xrFrame xr frame to update the pose with
  108113. * @param referenceSpace reference space to use
  108114. */
  108115. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  108116. /**
  108117. * Gets a world space ray coming from the controller
  108118. * @param result the resulting ray
  108119. */
  108120. getWorldPointerRayToRef(result: Ray): void;
  108121. /**
  108122. * Disposes of the object
  108123. */
  108124. dispose(): void;
  108125. }
  108126. }
  108127. declare module BABYLON {
  108128. /**
  108129. * XR input used to track XR inputs such as controllers/rays
  108130. */
  108131. export class WebXRInput implements IDisposable {
  108132. /**
  108133. * Base experience the input listens to
  108134. */
  108135. baseExperience: WebXRExperienceHelper;
  108136. /**
  108137. * XR controllers being tracked
  108138. */
  108139. controllers: Array<WebXRController>;
  108140. private _frameObserver;
  108141. private _stateObserver;
  108142. /**
  108143. * Event when a controller has been connected/added
  108144. */
  108145. onControllerAddedObservable: Observable<WebXRController>;
  108146. /**
  108147. * Event when a controller has been removed/disconnected
  108148. */
  108149. onControllerRemovedObservable: Observable<WebXRController>;
  108150. /**
  108151. * Initializes the WebXRInput
  108152. * @param baseExperience experience helper which the input should be created for
  108153. */
  108154. constructor(
  108155. /**
  108156. * Base experience the input listens to
  108157. */
  108158. baseExperience: WebXRExperienceHelper);
  108159. private _onInputSourcesChange;
  108160. private _addAndRemoveControllers;
  108161. /**
  108162. * Disposes of the object
  108163. */
  108164. dispose(): void;
  108165. }
  108166. }
  108167. declare module BABYLON {
  108168. /**
  108169. * Enables teleportation
  108170. */
  108171. export class WebXRControllerTeleportation {
  108172. private _teleportationFillColor;
  108173. private _teleportationBorderColor;
  108174. private _tmpRay;
  108175. private _tmpVector;
  108176. /**
  108177. * Creates a WebXRControllerTeleportation
  108178. * @param input input manager to add teleportation to
  108179. * @param floorMeshes floormeshes which can be teleported to
  108180. */
  108181. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  108182. }
  108183. }
  108184. declare module BABYLON {
  108185. /**
  108186. * Handles pointer input automatically for the pointer of XR controllers
  108187. */
  108188. export class WebXRControllerPointerSelection {
  108189. private static _idCounter;
  108190. private _tmpRay;
  108191. /**
  108192. * Creates a WebXRControllerPointerSelection
  108193. * @param input input manager to setup pointer selection
  108194. */
  108195. constructor(input: WebXRInput);
  108196. private _convertNormalToDirectionOfRay;
  108197. private _updatePointerDistance;
  108198. }
  108199. }
  108200. declare module BABYLON {
  108201. /**
  108202. * Class used to represent data loading progression
  108203. */
  108204. export class SceneLoaderProgressEvent {
  108205. /** defines if data length to load can be evaluated */
  108206. readonly lengthComputable: boolean;
  108207. /** defines the loaded data length */
  108208. readonly loaded: number;
  108209. /** defines the data length to load */
  108210. readonly total: number;
  108211. /**
  108212. * Create a new progress event
  108213. * @param lengthComputable defines if data length to load can be evaluated
  108214. * @param loaded defines the loaded data length
  108215. * @param total defines the data length to load
  108216. */
  108217. constructor(
  108218. /** defines if data length to load can be evaluated */
  108219. lengthComputable: boolean,
  108220. /** defines the loaded data length */
  108221. loaded: number,
  108222. /** defines the data length to load */
  108223. total: number);
  108224. /**
  108225. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  108226. * @param event defines the source event
  108227. * @returns a new SceneLoaderProgressEvent
  108228. */
  108229. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  108230. }
  108231. /**
  108232. * Interface used by SceneLoader plugins to define supported file extensions
  108233. */
  108234. export interface ISceneLoaderPluginExtensions {
  108235. /**
  108236. * Defines the list of supported extensions
  108237. */
  108238. [extension: string]: {
  108239. isBinary: boolean;
  108240. };
  108241. }
  108242. /**
  108243. * Interface used by SceneLoader plugin factory
  108244. */
  108245. export interface ISceneLoaderPluginFactory {
  108246. /**
  108247. * Defines the name of the factory
  108248. */
  108249. name: string;
  108250. /**
  108251. * Function called to create a new plugin
  108252. * @return the new plugin
  108253. */
  108254. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  108255. /**
  108256. * Boolean indicating if the plugin can direct load specific data
  108257. */
  108258. canDirectLoad?: (data: string) => boolean;
  108259. }
  108260. /**
  108261. * Interface used to define a SceneLoader plugin
  108262. */
  108263. export interface ISceneLoaderPlugin {
  108264. /**
  108265. * The friendly name of this plugin.
  108266. */
  108267. name: string;
  108268. /**
  108269. * The file extensions supported by this plugin.
  108270. */
  108271. extensions: string | ISceneLoaderPluginExtensions;
  108272. /**
  108273. * Import meshes into a scene.
  108274. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108275. * @param scene The scene to import into
  108276. * @param data The data to import
  108277. * @param rootUrl The root url for scene and resources
  108278. * @param meshes The meshes array to import into
  108279. * @param particleSystems The particle systems array to import into
  108280. * @param skeletons The skeletons array to import into
  108281. * @param onError The callback when import fails
  108282. * @returns True if successful or false otherwise
  108283. */
  108284. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  108285. /**
  108286. * Load into a scene.
  108287. * @param scene The scene to load into
  108288. * @param data The data to import
  108289. * @param rootUrl The root url for scene and resources
  108290. * @param onError The callback when import fails
  108291. * @returns true if successful or false otherwise
  108292. */
  108293. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  108294. /**
  108295. * The callback that returns true if the data can be directly loaded.
  108296. */
  108297. canDirectLoad?: (data: string) => boolean;
  108298. /**
  108299. * The callback that allows custom handling of the root url based on the response url.
  108300. */
  108301. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108302. /**
  108303. * Load into an asset container.
  108304. * @param scene The scene to load into
  108305. * @param data The data to import
  108306. * @param rootUrl The root url for scene and resources
  108307. * @param onError The callback when import fails
  108308. * @returns The loaded asset container
  108309. */
  108310. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  108311. }
  108312. /**
  108313. * Interface used to define an async SceneLoader plugin
  108314. */
  108315. export interface ISceneLoaderPluginAsync {
  108316. /**
  108317. * The friendly name of this plugin.
  108318. */
  108319. name: string;
  108320. /**
  108321. * The file extensions supported by this plugin.
  108322. */
  108323. extensions: string | ISceneLoaderPluginExtensions;
  108324. /**
  108325. * Import meshes into a scene.
  108326. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108327. * @param scene The scene to import into
  108328. * @param data The data to import
  108329. * @param rootUrl The root url for scene and resources
  108330. * @param onProgress The callback when the load progresses
  108331. * @param fileName Defines the name of the file to load
  108332. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  108333. */
  108334. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  108335. meshes: AbstractMesh[];
  108336. particleSystems: IParticleSystem[];
  108337. skeletons: Skeleton[];
  108338. animationGroups: AnimationGroup[];
  108339. }>;
  108340. /**
  108341. * Load into a scene.
  108342. * @param scene The scene to load into
  108343. * @param data The data to import
  108344. * @param rootUrl The root url for scene and resources
  108345. * @param onProgress The callback when the load progresses
  108346. * @param fileName Defines the name of the file to load
  108347. * @returns Nothing
  108348. */
  108349. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  108350. /**
  108351. * The callback that returns true if the data can be directly loaded.
  108352. */
  108353. canDirectLoad?: (data: string) => boolean;
  108354. /**
  108355. * The callback that allows custom handling of the root url based on the response url.
  108356. */
  108357. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108358. /**
  108359. * Load into an asset container.
  108360. * @param scene The scene to load into
  108361. * @param data The data to import
  108362. * @param rootUrl The root url for scene and resources
  108363. * @param onProgress The callback when the load progresses
  108364. * @param fileName Defines the name of the file to load
  108365. * @returns The loaded asset container
  108366. */
  108367. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  108368. }
  108369. /**
  108370. * Class used to load scene from various file formats using registered plugins
  108371. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  108372. */
  108373. export class SceneLoader {
  108374. /**
  108375. * No logging while loading
  108376. */
  108377. static readonly NO_LOGGING: number;
  108378. /**
  108379. * Minimal logging while loading
  108380. */
  108381. static readonly MINIMAL_LOGGING: number;
  108382. /**
  108383. * Summary logging while loading
  108384. */
  108385. static readonly SUMMARY_LOGGING: number;
  108386. /**
  108387. * Detailled logging while loading
  108388. */
  108389. static readonly DETAILED_LOGGING: number;
  108390. /**
  108391. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  108392. */
  108393. static ForceFullSceneLoadingForIncremental: boolean;
  108394. /**
  108395. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  108396. */
  108397. static ShowLoadingScreen: boolean;
  108398. /**
  108399. * Defines the current logging level (while loading the scene)
  108400. * @ignorenaming
  108401. */
  108402. static loggingLevel: number;
  108403. /**
  108404. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  108405. */
  108406. static CleanBoneMatrixWeights: boolean;
  108407. /**
  108408. * Event raised when a plugin is used to load a scene
  108409. */
  108410. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  108411. private static _registeredPlugins;
  108412. private static _getDefaultPlugin;
  108413. private static _getPluginForExtension;
  108414. private static _getPluginForDirectLoad;
  108415. private static _getPluginForFilename;
  108416. private static _getDirectLoad;
  108417. private static _loadData;
  108418. private static _getFileInfo;
  108419. /**
  108420. * Gets a plugin that can load the given extension
  108421. * @param extension defines the extension to load
  108422. * @returns a plugin or null if none works
  108423. */
  108424. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  108425. /**
  108426. * Gets a boolean indicating that the given extension can be loaded
  108427. * @param extension defines the extension to load
  108428. * @returns true if the extension is supported
  108429. */
  108430. static IsPluginForExtensionAvailable(extension: string): boolean;
  108431. /**
  108432. * Adds a new plugin to the list of registered plugins
  108433. * @param plugin defines the plugin to add
  108434. */
  108435. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  108436. /**
  108437. * Import meshes into a scene
  108438. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108439. * @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)
  108440. * @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)
  108441. * @param scene the instance of BABYLON.Scene to append to
  108442. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  108443. * @param onProgress a callback with a progress event for each file being loaded
  108444. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108445. * @param pluginExtension the extension used to determine the plugin
  108446. * @returns The loaded plugin
  108447. */
  108448. 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>;
  108449. /**
  108450. * Import meshes into a scene
  108451. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108452. * @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)
  108453. * @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)
  108454. * @param scene the instance of BABYLON.Scene to append to
  108455. * @param onProgress a callback with a progress event for each file being loaded
  108456. * @param pluginExtension the extension used to determine the plugin
  108457. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  108458. */
  108459. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  108460. meshes: AbstractMesh[];
  108461. particleSystems: IParticleSystem[];
  108462. skeletons: Skeleton[];
  108463. animationGroups: AnimationGroup[];
  108464. }>;
  108465. /**
  108466. * Load a scene
  108467. * @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)
  108468. * @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)
  108469. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108470. * @param onSuccess a callback with the scene when import succeeds
  108471. * @param onProgress a callback with a progress event for each file being loaded
  108472. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108473. * @param pluginExtension the extension used to determine the plugin
  108474. * @returns The loaded plugin
  108475. */
  108476. 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>;
  108477. /**
  108478. * Load a scene
  108479. * @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)
  108480. * @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)
  108481. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108482. * @param onProgress a callback with a progress event for each file being loaded
  108483. * @param pluginExtension the extension used to determine the plugin
  108484. * @returns The loaded scene
  108485. */
  108486. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108487. /**
  108488. * Append a scene
  108489. * @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)
  108490. * @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)
  108491. * @param scene is the instance of BABYLON.Scene to append to
  108492. * @param onSuccess a callback with the scene when import succeeds
  108493. * @param onProgress a callback with a progress event for each file being loaded
  108494. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108495. * @param pluginExtension the extension used to determine the plugin
  108496. * @returns The loaded plugin
  108497. */
  108498. 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>;
  108499. /**
  108500. * Append a scene
  108501. * @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)
  108502. * @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)
  108503. * @param scene is the instance of BABYLON.Scene to append to
  108504. * @param onProgress a callback with a progress event for each file being loaded
  108505. * @param pluginExtension the extension used to determine the plugin
  108506. * @returns The given scene
  108507. */
  108508. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108509. /**
  108510. * Load a scene into an asset container
  108511. * @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)
  108512. * @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)
  108513. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  108514. * @param onSuccess a callback with the scene when import succeeds
  108515. * @param onProgress a callback with a progress event for each file being loaded
  108516. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108517. * @param pluginExtension the extension used to determine the plugin
  108518. * @returns The loaded plugin
  108519. */
  108520. 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>;
  108521. /**
  108522. * Load a scene into an asset container
  108523. * @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)
  108524. * @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)
  108525. * @param scene is the instance of Scene to append to
  108526. * @param onProgress a callback with a progress event for each file being loaded
  108527. * @param pluginExtension the extension used to determine the plugin
  108528. * @returns The loaded asset container
  108529. */
  108530. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  108531. }
  108532. }
  108533. declare module BABYLON {
  108534. /**
  108535. * Generic Controller
  108536. */
  108537. export class GenericController extends WebVRController {
  108538. /**
  108539. * Base Url for the controller model.
  108540. */
  108541. static readonly MODEL_BASE_URL: string;
  108542. /**
  108543. * File name for the controller model.
  108544. */
  108545. static readonly MODEL_FILENAME: string;
  108546. /**
  108547. * Creates a new GenericController from a gamepad
  108548. * @param vrGamepad the gamepad that the controller should be created from
  108549. */
  108550. constructor(vrGamepad: any);
  108551. /**
  108552. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108553. * @param scene scene in which to add meshes
  108554. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108555. */
  108556. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108557. /**
  108558. * Called once for each button that changed state since the last frame
  108559. * @param buttonIdx Which button index changed
  108560. * @param state New state of the button
  108561. * @param changes Which properties on the state changed since last frame
  108562. */
  108563. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108564. }
  108565. }
  108566. declare module BABYLON {
  108567. /**
  108568. * Defines the WindowsMotionController object that the state of the windows motion controller
  108569. */
  108570. export class WindowsMotionController extends WebVRController {
  108571. /**
  108572. * The base url used to load the left and right controller models
  108573. */
  108574. static MODEL_BASE_URL: string;
  108575. /**
  108576. * The name of the left controller model file
  108577. */
  108578. static MODEL_LEFT_FILENAME: string;
  108579. /**
  108580. * The name of the right controller model file
  108581. */
  108582. static MODEL_RIGHT_FILENAME: string;
  108583. /**
  108584. * The controller name prefix for this controller type
  108585. */
  108586. static readonly GAMEPAD_ID_PREFIX: string;
  108587. /**
  108588. * The controller id pattern for this controller type
  108589. */
  108590. private static readonly GAMEPAD_ID_PATTERN;
  108591. private _loadedMeshInfo;
  108592. private readonly _mapping;
  108593. /**
  108594. * Fired when the trackpad on this controller is clicked
  108595. */
  108596. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  108597. /**
  108598. * Fired when the trackpad on this controller is modified
  108599. */
  108600. onTrackpadValuesChangedObservable: Observable<StickValues>;
  108601. /**
  108602. * The current x and y values of this controller's trackpad
  108603. */
  108604. trackpad: StickValues;
  108605. /**
  108606. * Creates a new WindowsMotionController from a gamepad
  108607. * @param vrGamepad the gamepad that the controller should be created from
  108608. */
  108609. constructor(vrGamepad: any);
  108610. /**
  108611. * Fired when the trigger on this controller is modified
  108612. */
  108613. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108614. /**
  108615. * Fired when the menu button on this controller is modified
  108616. */
  108617. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108618. /**
  108619. * Fired when the grip button on this controller is modified
  108620. */
  108621. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108622. /**
  108623. * Fired when the thumbstick button on this controller is modified
  108624. */
  108625. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108626. /**
  108627. * Fired when the touchpad button on this controller is modified
  108628. */
  108629. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108630. /**
  108631. * Fired when the touchpad values on this controller are modified
  108632. */
  108633. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  108634. private _updateTrackpad;
  108635. /**
  108636. * Called once per frame by the engine.
  108637. */
  108638. update(): void;
  108639. /**
  108640. * Called once for each button that changed state since the last frame
  108641. * @param buttonIdx Which button index changed
  108642. * @param state New state of the button
  108643. * @param changes Which properties on the state changed since last frame
  108644. */
  108645. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108646. /**
  108647. * Moves the buttons on the controller mesh based on their current state
  108648. * @param buttonName the name of the button to move
  108649. * @param buttonValue the value of the button which determines the buttons new position
  108650. */
  108651. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  108652. /**
  108653. * Moves the axis on the controller mesh based on its current state
  108654. * @param axis the index of the axis
  108655. * @param axisValue the value of the axis which determines the meshes new position
  108656. * @hidden
  108657. */
  108658. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  108659. /**
  108660. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108661. * @param scene scene in which to add meshes
  108662. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108663. */
  108664. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  108665. /**
  108666. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  108667. * can be transformed by button presses and axes values, based on this._mapping.
  108668. *
  108669. * @param scene scene in which the meshes exist
  108670. * @param meshes list of meshes that make up the controller model to process
  108671. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  108672. */
  108673. private processModel;
  108674. private createMeshInfo;
  108675. /**
  108676. * Gets the ray of the controller in the direction the controller is pointing
  108677. * @param length the length the resulting ray should be
  108678. * @returns a ray in the direction the controller is pointing
  108679. */
  108680. getForwardRay(length?: number): Ray;
  108681. /**
  108682. * Disposes of the controller
  108683. */
  108684. dispose(): void;
  108685. }
  108686. }
  108687. declare module BABYLON {
  108688. /**
  108689. * Oculus Touch Controller
  108690. */
  108691. export class OculusTouchController extends WebVRController {
  108692. /**
  108693. * Base Url for the controller model.
  108694. */
  108695. static MODEL_BASE_URL: string;
  108696. /**
  108697. * File name for the left controller model.
  108698. */
  108699. static MODEL_LEFT_FILENAME: string;
  108700. /**
  108701. * File name for the right controller model.
  108702. */
  108703. static MODEL_RIGHT_FILENAME: string;
  108704. /**
  108705. * Base Url for the Quest controller model.
  108706. */
  108707. static QUEST_MODEL_BASE_URL: string;
  108708. /**
  108709. * @hidden
  108710. * If the controllers are running on a device that needs the updated Quest controller models
  108711. */
  108712. static _IsQuest: boolean;
  108713. /**
  108714. * Fired when the secondary trigger on this controller is modified
  108715. */
  108716. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  108717. /**
  108718. * Fired when the thumb rest on this controller is modified
  108719. */
  108720. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  108721. /**
  108722. * Creates a new OculusTouchController from a gamepad
  108723. * @param vrGamepad the gamepad that the controller should be created from
  108724. */
  108725. constructor(vrGamepad: any);
  108726. /**
  108727. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108728. * @param scene scene in which to add meshes
  108729. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108730. */
  108731. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108732. /**
  108733. * Fired when the A button on this controller is modified
  108734. */
  108735. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108736. /**
  108737. * Fired when the B button on this controller is modified
  108738. */
  108739. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108740. /**
  108741. * Fired when the X button on this controller is modified
  108742. */
  108743. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108744. /**
  108745. * Fired when the Y button on this controller is modified
  108746. */
  108747. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108748. /**
  108749. * Called once for each button that changed state since the last frame
  108750. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  108751. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  108752. * 2) secondary trigger (same)
  108753. * 3) A (right) X (left), touch, pressed = value
  108754. * 4) B / Y
  108755. * 5) thumb rest
  108756. * @param buttonIdx Which button index changed
  108757. * @param state New state of the button
  108758. * @param changes Which properties on the state changed since last frame
  108759. */
  108760. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108761. }
  108762. }
  108763. declare module BABYLON {
  108764. /**
  108765. * Vive Controller
  108766. */
  108767. export class ViveController extends WebVRController {
  108768. /**
  108769. * Base Url for the controller model.
  108770. */
  108771. static MODEL_BASE_URL: string;
  108772. /**
  108773. * File name for the controller model.
  108774. */
  108775. static MODEL_FILENAME: string;
  108776. /**
  108777. * Creates a new ViveController from a gamepad
  108778. * @param vrGamepad the gamepad that the controller should be created from
  108779. */
  108780. constructor(vrGamepad: any);
  108781. /**
  108782. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108783. * @param scene scene in which to add meshes
  108784. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108785. */
  108786. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108787. /**
  108788. * Fired when the left button on this controller is modified
  108789. */
  108790. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108791. /**
  108792. * Fired when the right button on this controller is modified
  108793. */
  108794. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108795. /**
  108796. * Fired when the menu button on this controller is modified
  108797. */
  108798. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108799. /**
  108800. * Called once for each button that changed state since the last frame
  108801. * Vive mapping:
  108802. * 0: touchpad
  108803. * 1: trigger
  108804. * 2: left AND right buttons
  108805. * 3: menu button
  108806. * @param buttonIdx Which button index changed
  108807. * @param state New state of the button
  108808. * @param changes Which properties on the state changed since last frame
  108809. */
  108810. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108811. }
  108812. }
  108813. declare module BABYLON {
  108814. /**
  108815. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  108816. */
  108817. export class WebXRControllerModelLoader {
  108818. /**
  108819. * Creates the WebXRControllerModelLoader
  108820. * @param input xr input that creates the controllers
  108821. */
  108822. constructor(input: WebXRInput);
  108823. }
  108824. }
  108825. declare module BABYLON {
  108826. /**
  108827. * Contains an array of blocks representing the octree
  108828. */
  108829. export interface IOctreeContainer<T> {
  108830. /**
  108831. * Blocks within the octree
  108832. */
  108833. blocks: Array<OctreeBlock<T>>;
  108834. }
  108835. /**
  108836. * Class used to store a cell in an octree
  108837. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108838. */
  108839. export class OctreeBlock<T> {
  108840. /**
  108841. * Gets the content of the current block
  108842. */
  108843. entries: T[];
  108844. /**
  108845. * Gets the list of block children
  108846. */
  108847. blocks: Array<OctreeBlock<T>>;
  108848. private _depth;
  108849. private _maxDepth;
  108850. private _capacity;
  108851. private _minPoint;
  108852. private _maxPoint;
  108853. private _boundingVectors;
  108854. private _creationFunc;
  108855. /**
  108856. * Creates a new block
  108857. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  108858. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  108859. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108860. * @param depth defines the current depth of this block in the octree
  108861. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  108862. * @param creationFunc defines a callback to call when an element is added to the block
  108863. */
  108864. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  108865. /**
  108866. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108867. */
  108868. readonly capacity: number;
  108869. /**
  108870. * Gets the minimum vector (in world space) of the block's bounding box
  108871. */
  108872. readonly minPoint: Vector3;
  108873. /**
  108874. * Gets the maximum vector (in world space) of the block's bounding box
  108875. */
  108876. readonly maxPoint: Vector3;
  108877. /**
  108878. * Add a new element to this block
  108879. * @param entry defines the element to add
  108880. */
  108881. addEntry(entry: T): void;
  108882. /**
  108883. * Remove an element from this block
  108884. * @param entry defines the element to remove
  108885. */
  108886. removeEntry(entry: T): void;
  108887. /**
  108888. * Add an array of elements to this block
  108889. * @param entries defines the array of elements to add
  108890. */
  108891. addEntries(entries: T[]): void;
  108892. /**
  108893. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  108894. * @param frustumPlanes defines the frustum planes to test
  108895. * @param selection defines the array to store current content if selection is positive
  108896. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108897. */
  108898. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108899. /**
  108900. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  108901. * @param sphereCenter defines the bounding sphere center
  108902. * @param sphereRadius defines the bounding sphere radius
  108903. * @param selection defines the array to store current content if selection is positive
  108904. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108905. */
  108906. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108907. /**
  108908. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  108909. * @param ray defines the ray to test with
  108910. * @param selection defines the array to store current content if selection is positive
  108911. */
  108912. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  108913. /**
  108914. * Subdivide the content into child blocks (this block will then be empty)
  108915. */
  108916. createInnerBlocks(): void;
  108917. /**
  108918. * @hidden
  108919. */
  108920. 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;
  108921. }
  108922. }
  108923. declare module BABYLON {
  108924. /**
  108925. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  108926. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108927. */
  108928. export class Octree<T> {
  108929. /** 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.) */
  108930. maxDepth: number;
  108931. /**
  108932. * Blocks within the octree containing objects
  108933. */
  108934. blocks: Array<OctreeBlock<T>>;
  108935. /**
  108936. * Content stored in the octree
  108937. */
  108938. dynamicContent: T[];
  108939. private _maxBlockCapacity;
  108940. private _selectionContent;
  108941. private _creationFunc;
  108942. /**
  108943. * Creates a octree
  108944. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108945. * @param creationFunc function to be used to instatiate the octree
  108946. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  108947. * @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.)
  108948. */
  108949. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  108950. /** 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.) */
  108951. maxDepth?: number);
  108952. /**
  108953. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  108954. * @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);
  108955. * @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);
  108956. * @param entries meshes to be added to the octree blocks
  108957. */
  108958. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  108959. /**
  108960. * Adds a mesh to the octree
  108961. * @param entry Mesh to add to the octree
  108962. */
  108963. addMesh(entry: T): void;
  108964. /**
  108965. * Remove an element from the octree
  108966. * @param entry defines the element to remove
  108967. */
  108968. removeMesh(entry: T): void;
  108969. /**
  108970. * Selects an array of meshes within the frustum
  108971. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  108972. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  108973. * @returns array of meshes within the frustum
  108974. */
  108975. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  108976. /**
  108977. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  108978. * @param sphereCenter defines the bounding sphere center
  108979. * @param sphereRadius defines the bounding sphere radius
  108980. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108981. * @returns an array of objects that intersect the sphere
  108982. */
  108983. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  108984. /**
  108985. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  108986. * @param ray defines the ray to test with
  108987. * @returns array of intersected objects
  108988. */
  108989. intersectsRay(ray: Ray): SmartArray<T>;
  108990. /**
  108991. * Adds a mesh into the octree block if it intersects the block
  108992. */
  108993. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  108994. /**
  108995. * Adds a submesh into the octree block if it intersects the block
  108996. */
  108997. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  108998. }
  108999. }
  109000. declare module BABYLON {
  109001. interface Scene {
  109002. /**
  109003. * @hidden
  109004. * Backing Filed
  109005. */
  109006. _selectionOctree: Octree<AbstractMesh>;
  109007. /**
  109008. * Gets the octree used to boost mesh selection (picking)
  109009. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109010. */
  109011. selectionOctree: Octree<AbstractMesh>;
  109012. /**
  109013. * Creates or updates the octree used to boost selection (picking)
  109014. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109015. * @param maxCapacity defines the maximum capacity per leaf
  109016. * @param maxDepth defines the maximum depth of the octree
  109017. * @returns an octree of AbstractMesh
  109018. */
  109019. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  109020. }
  109021. interface AbstractMesh {
  109022. /**
  109023. * @hidden
  109024. * Backing Field
  109025. */
  109026. _submeshesOctree: Octree<SubMesh>;
  109027. /**
  109028. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  109029. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  109030. * @param maxCapacity defines the maximum size of each block (64 by default)
  109031. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  109032. * @returns the new octree
  109033. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  109034. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109035. */
  109036. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  109037. }
  109038. /**
  109039. * Defines the octree scene component responsible to manage any octrees
  109040. * in a given scene.
  109041. */
  109042. export class OctreeSceneComponent {
  109043. /**
  109044. * The component name help to identify the component in the list of scene components.
  109045. */
  109046. readonly name: string;
  109047. /**
  109048. * The scene the component belongs to.
  109049. */
  109050. scene: Scene;
  109051. /**
  109052. * Indicates if the meshes have been checked to make sure they are isEnabled()
  109053. */
  109054. readonly checksIsEnabled: boolean;
  109055. /**
  109056. * Creates a new instance of the component for the given scene
  109057. * @param scene Defines the scene to register the component in
  109058. */
  109059. constructor(scene: Scene);
  109060. /**
  109061. * Registers the component in a given scene
  109062. */
  109063. register(): void;
  109064. /**
  109065. * Return the list of active meshes
  109066. * @returns the list of active meshes
  109067. */
  109068. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109069. /**
  109070. * Return the list of active sub meshes
  109071. * @param mesh The mesh to get the candidates sub meshes from
  109072. * @returns the list of active sub meshes
  109073. */
  109074. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109075. private _tempRay;
  109076. /**
  109077. * Return the list of sub meshes intersecting with a given local ray
  109078. * @param mesh defines the mesh to find the submesh for
  109079. * @param localRay defines the ray in local space
  109080. * @returns the list of intersecting sub meshes
  109081. */
  109082. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  109083. /**
  109084. * Return the list of sub meshes colliding with a collider
  109085. * @param mesh defines the mesh to find the submesh for
  109086. * @param collider defines the collider to evaluate the collision against
  109087. * @returns the list of colliding sub meshes
  109088. */
  109089. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  109090. /**
  109091. * Rebuilds the elements related to this component in case of
  109092. * context lost for instance.
  109093. */
  109094. rebuild(): void;
  109095. /**
  109096. * Disposes the component and the associated ressources.
  109097. */
  109098. dispose(): void;
  109099. }
  109100. }
  109101. declare module BABYLON {
  109102. /**
  109103. * Renders a layer on top of an existing scene
  109104. */
  109105. export class UtilityLayerRenderer implements IDisposable {
  109106. /** the original scene that will be rendered on top of */
  109107. originalScene: Scene;
  109108. private _pointerCaptures;
  109109. private _lastPointerEvents;
  109110. private static _DefaultUtilityLayer;
  109111. private static _DefaultKeepDepthUtilityLayer;
  109112. private _sharedGizmoLight;
  109113. private _renderCamera;
  109114. /**
  109115. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  109116. * @returns the camera that is used when rendering the utility layer
  109117. */
  109118. getRenderCamera(): Nullable<Camera>;
  109119. /**
  109120. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  109121. * @param cam the camera that should be used when rendering the utility layer
  109122. */
  109123. setRenderCamera(cam: Nullable<Camera>): void;
  109124. /**
  109125. * @hidden
  109126. * Light which used by gizmos to get light shading
  109127. */
  109128. _getSharedGizmoLight(): HemisphericLight;
  109129. /**
  109130. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  109131. */
  109132. pickUtilitySceneFirst: boolean;
  109133. /**
  109134. * 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)
  109135. */
  109136. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  109137. /**
  109138. * 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)
  109139. */
  109140. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  109141. /**
  109142. * The scene that is rendered on top of the original scene
  109143. */
  109144. utilityLayerScene: Scene;
  109145. /**
  109146. * If the utility layer should automatically be rendered on top of existing scene
  109147. */
  109148. shouldRender: boolean;
  109149. /**
  109150. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  109151. */
  109152. onlyCheckPointerDownEvents: boolean;
  109153. /**
  109154. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  109155. */
  109156. processAllEvents: boolean;
  109157. /**
  109158. * Observable raised when the pointer move from the utility layer scene to the main scene
  109159. */
  109160. onPointerOutObservable: Observable<number>;
  109161. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  109162. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  109163. private _afterRenderObserver;
  109164. private _sceneDisposeObserver;
  109165. private _originalPointerObserver;
  109166. /**
  109167. * Instantiates a UtilityLayerRenderer
  109168. * @param originalScene the original scene that will be rendered on top of
  109169. * @param handleEvents boolean indicating if the utility layer should handle events
  109170. */
  109171. constructor(
  109172. /** the original scene that will be rendered on top of */
  109173. originalScene: Scene, handleEvents?: boolean);
  109174. private _notifyObservers;
  109175. /**
  109176. * Renders the utility layers scene on top of the original scene
  109177. */
  109178. render(): void;
  109179. /**
  109180. * Disposes of the renderer
  109181. */
  109182. dispose(): void;
  109183. private _updateCamera;
  109184. }
  109185. }
  109186. declare module BABYLON {
  109187. /**
  109188. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  109189. */
  109190. export class Gizmo implements IDisposable {
  109191. /** The utility layer the gizmo will be added to */
  109192. gizmoLayer: UtilityLayerRenderer;
  109193. /**
  109194. * The root mesh of the gizmo
  109195. */
  109196. _rootMesh: Mesh;
  109197. private _attachedMesh;
  109198. /**
  109199. * Ratio for the scale of the gizmo (Default: 1)
  109200. */
  109201. scaleRatio: number;
  109202. /**
  109203. * If a custom mesh has been set (Default: false)
  109204. */
  109205. protected _customMeshSet: boolean;
  109206. /**
  109207. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  109208. * * When set, interactions will be enabled
  109209. */
  109210. attachedMesh: Nullable<AbstractMesh>;
  109211. /**
  109212. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  109213. * @param mesh The mesh to replace the default mesh of the gizmo
  109214. */
  109215. setCustomMesh(mesh: Mesh): void;
  109216. /**
  109217. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  109218. */
  109219. updateGizmoRotationToMatchAttachedMesh: boolean;
  109220. /**
  109221. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  109222. */
  109223. updateGizmoPositionToMatchAttachedMesh: boolean;
  109224. /**
  109225. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  109226. */
  109227. updateScale: boolean;
  109228. protected _interactionsEnabled: boolean;
  109229. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109230. private _beforeRenderObserver;
  109231. private _tempVector;
  109232. /**
  109233. * Creates a gizmo
  109234. * @param gizmoLayer The utility layer the gizmo will be added to
  109235. */
  109236. constructor(
  109237. /** The utility layer the gizmo will be added to */
  109238. gizmoLayer?: UtilityLayerRenderer);
  109239. /**
  109240. * Updates the gizmo to match the attached mesh's position/rotation
  109241. */
  109242. protected _update(): void;
  109243. /**
  109244. * Disposes of the gizmo
  109245. */
  109246. dispose(): void;
  109247. }
  109248. }
  109249. declare module BABYLON {
  109250. /**
  109251. * Single plane drag gizmo
  109252. */
  109253. export class PlaneDragGizmo extends Gizmo {
  109254. /**
  109255. * Drag behavior responsible for the gizmos dragging interactions
  109256. */
  109257. dragBehavior: PointerDragBehavior;
  109258. private _pointerObserver;
  109259. /**
  109260. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109261. */
  109262. snapDistance: number;
  109263. /**
  109264. * Event that fires each time the gizmo snaps to a new location.
  109265. * * snapDistance is the the change in distance
  109266. */
  109267. onSnapObservable: Observable<{
  109268. snapDistance: number;
  109269. }>;
  109270. private _plane;
  109271. private _coloredMaterial;
  109272. private _hoverMaterial;
  109273. private _isEnabled;
  109274. private _parent;
  109275. /** @hidden */
  109276. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  109277. /** @hidden */
  109278. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109279. /**
  109280. * Creates a PlaneDragGizmo
  109281. * @param gizmoLayer The utility layer the gizmo will be added to
  109282. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  109283. * @param color The color of the gizmo
  109284. */
  109285. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109286. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109287. /**
  109288. * If the gizmo is enabled
  109289. */
  109290. isEnabled: boolean;
  109291. /**
  109292. * Disposes of the gizmo
  109293. */
  109294. dispose(): void;
  109295. }
  109296. }
  109297. declare module BABYLON {
  109298. /**
  109299. * Gizmo that enables dragging a mesh along 3 axis
  109300. */
  109301. export class PositionGizmo extends Gizmo {
  109302. /**
  109303. * Internal gizmo used for interactions on the x axis
  109304. */
  109305. xGizmo: AxisDragGizmo;
  109306. /**
  109307. * Internal gizmo used for interactions on the y axis
  109308. */
  109309. yGizmo: AxisDragGizmo;
  109310. /**
  109311. * Internal gizmo used for interactions on the z axis
  109312. */
  109313. zGizmo: AxisDragGizmo;
  109314. /**
  109315. * Internal gizmo used for interactions on the yz plane
  109316. */
  109317. xPlaneGizmo: PlaneDragGizmo;
  109318. /**
  109319. * Internal gizmo used for interactions on the xz plane
  109320. */
  109321. yPlaneGizmo: PlaneDragGizmo;
  109322. /**
  109323. * Internal gizmo used for interactions on the xy plane
  109324. */
  109325. zPlaneGizmo: PlaneDragGizmo;
  109326. /**
  109327. * private variables
  109328. */
  109329. private _meshAttached;
  109330. private _updateGizmoRotationToMatchAttachedMesh;
  109331. private _snapDistance;
  109332. private _scaleRatio;
  109333. /** Fires an event when any of it's sub gizmos are dragged */
  109334. onDragStartObservable: Observable<unknown>;
  109335. /** Fires an event when any of it's sub gizmos are released from dragging */
  109336. onDragEndObservable: Observable<unknown>;
  109337. /**
  109338. * If set to true, planar drag is enabled
  109339. */
  109340. private _planarGizmoEnabled;
  109341. attachedMesh: Nullable<AbstractMesh>;
  109342. /**
  109343. * Creates a PositionGizmo
  109344. * @param gizmoLayer The utility layer the gizmo will be added to
  109345. */
  109346. constructor(gizmoLayer?: UtilityLayerRenderer);
  109347. /**
  109348. * If the planar drag gizmo is enabled
  109349. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  109350. */
  109351. planarGizmoEnabled: boolean;
  109352. updateGizmoRotationToMatchAttachedMesh: boolean;
  109353. /**
  109354. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109355. */
  109356. snapDistance: number;
  109357. /**
  109358. * Ratio for the scale of the gizmo (Default: 1)
  109359. */
  109360. scaleRatio: number;
  109361. /**
  109362. * Disposes of the gizmo
  109363. */
  109364. dispose(): void;
  109365. /**
  109366. * CustomMeshes are not supported by this gizmo
  109367. * @param mesh The mesh to replace the default mesh of the gizmo
  109368. */
  109369. setCustomMesh(mesh: Mesh): void;
  109370. }
  109371. }
  109372. declare module BABYLON {
  109373. /**
  109374. * Single axis drag gizmo
  109375. */
  109376. export class AxisDragGizmo extends Gizmo {
  109377. /**
  109378. * Drag behavior responsible for the gizmos dragging interactions
  109379. */
  109380. dragBehavior: PointerDragBehavior;
  109381. private _pointerObserver;
  109382. /**
  109383. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109384. */
  109385. snapDistance: number;
  109386. /**
  109387. * Event that fires each time the gizmo snaps to a new location.
  109388. * * snapDistance is the the change in distance
  109389. */
  109390. onSnapObservable: Observable<{
  109391. snapDistance: number;
  109392. }>;
  109393. private _isEnabled;
  109394. private _parent;
  109395. private _arrow;
  109396. private _coloredMaterial;
  109397. private _hoverMaterial;
  109398. /** @hidden */
  109399. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  109400. /** @hidden */
  109401. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109402. /**
  109403. * Creates an AxisDragGizmo
  109404. * @param gizmoLayer The utility layer the gizmo will be added to
  109405. * @param dragAxis The axis which the gizmo will be able to drag on
  109406. * @param color The color of the gizmo
  109407. */
  109408. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109409. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109410. /**
  109411. * If the gizmo is enabled
  109412. */
  109413. isEnabled: boolean;
  109414. /**
  109415. * Disposes of the gizmo
  109416. */
  109417. dispose(): void;
  109418. }
  109419. }
  109420. declare module BABYLON.Debug {
  109421. /**
  109422. * The Axes viewer will show 3 axes in a specific point in space
  109423. */
  109424. export class AxesViewer {
  109425. private _xAxis;
  109426. private _yAxis;
  109427. private _zAxis;
  109428. private _scaleLinesFactor;
  109429. private _instanced;
  109430. /**
  109431. * Gets the hosting scene
  109432. */
  109433. scene: Scene;
  109434. /**
  109435. * Gets or sets a number used to scale line length
  109436. */
  109437. scaleLines: number;
  109438. /** Gets the node hierarchy used to render x-axis */
  109439. readonly xAxis: TransformNode;
  109440. /** Gets the node hierarchy used to render y-axis */
  109441. readonly yAxis: TransformNode;
  109442. /** Gets the node hierarchy used to render z-axis */
  109443. readonly zAxis: TransformNode;
  109444. /**
  109445. * Creates a new AxesViewer
  109446. * @param scene defines the hosting scene
  109447. * @param scaleLines defines a number used to scale line length (1 by default)
  109448. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  109449. * @param xAxis defines the node hierarchy used to render the x-axis
  109450. * @param yAxis defines the node hierarchy used to render the y-axis
  109451. * @param zAxis defines the node hierarchy used to render the z-axis
  109452. */
  109453. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  109454. /**
  109455. * Force the viewer to update
  109456. * @param position defines the position of the viewer
  109457. * @param xaxis defines the x axis of the viewer
  109458. * @param yaxis defines the y axis of the viewer
  109459. * @param zaxis defines the z axis of the viewer
  109460. */
  109461. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  109462. /**
  109463. * Creates an instance of this axes viewer.
  109464. * @returns a new axes viewer with instanced meshes
  109465. */
  109466. createInstance(): AxesViewer;
  109467. /** Releases resources */
  109468. dispose(): void;
  109469. private static _SetRenderingGroupId;
  109470. }
  109471. }
  109472. declare module BABYLON.Debug {
  109473. /**
  109474. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  109475. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  109476. */
  109477. export class BoneAxesViewer extends AxesViewer {
  109478. /**
  109479. * Gets or sets the target mesh where to display the axes viewer
  109480. */
  109481. mesh: Nullable<Mesh>;
  109482. /**
  109483. * Gets or sets the target bone where to display the axes viewer
  109484. */
  109485. bone: Nullable<Bone>;
  109486. /** Gets current position */
  109487. pos: Vector3;
  109488. /** Gets direction of X axis */
  109489. xaxis: Vector3;
  109490. /** Gets direction of Y axis */
  109491. yaxis: Vector3;
  109492. /** Gets direction of Z axis */
  109493. zaxis: Vector3;
  109494. /**
  109495. * Creates a new BoneAxesViewer
  109496. * @param scene defines the hosting scene
  109497. * @param bone defines the target bone
  109498. * @param mesh defines the target mesh
  109499. * @param scaleLines defines a scaling factor for line length (1 by default)
  109500. */
  109501. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  109502. /**
  109503. * Force the viewer to update
  109504. */
  109505. update(): void;
  109506. /** Releases resources */
  109507. dispose(): void;
  109508. }
  109509. }
  109510. declare module BABYLON {
  109511. /**
  109512. * Interface used to define scene explorer extensibility option
  109513. */
  109514. export interface IExplorerExtensibilityOption {
  109515. /**
  109516. * Define the option label
  109517. */
  109518. label: string;
  109519. /**
  109520. * Defines the action to execute on click
  109521. */
  109522. action: (entity: any) => void;
  109523. }
  109524. /**
  109525. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  109526. */
  109527. export interface IExplorerExtensibilityGroup {
  109528. /**
  109529. * Defines a predicate to test if a given type mut be extended
  109530. */
  109531. predicate: (entity: any) => boolean;
  109532. /**
  109533. * Gets the list of options added to a type
  109534. */
  109535. entries: IExplorerExtensibilityOption[];
  109536. }
  109537. /**
  109538. * Interface used to define the options to use to create the Inspector
  109539. */
  109540. export interface IInspectorOptions {
  109541. /**
  109542. * Display in overlay mode (default: false)
  109543. */
  109544. overlay?: boolean;
  109545. /**
  109546. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  109547. */
  109548. globalRoot?: HTMLElement;
  109549. /**
  109550. * Display the Scene explorer
  109551. */
  109552. showExplorer?: boolean;
  109553. /**
  109554. * Display the property inspector
  109555. */
  109556. showInspector?: boolean;
  109557. /**
  109558. * Display in embed mode (both panes on the right)
  109559. */
  109560. embedMode?: boolean;
  109561. /**
  109562. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  109563. */
  109564. handleResize?: boolean;
  109565. /**
  109566. * Allow the panes to popup (default: true)
  109567. */
  109568. enablePopup?: boolean;
  109569. /**
  109570. * Allow the panes to be closed by users (default: true)
  109571. */
  109572. enableClose?: boolean;
  109573. /**
  109574. * Optional list of extensibility entries
  109575. */
  109576. explorerExtensibility?: IExplorerExtensibilityGroup[];
  109577. /**
  109578. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  109579. */
  109580. inspectorURL?: string;
  109581. }
  109582. interface Scene {
  109583. /**
  109584. * @hidden
  109585. * Backing field
  109586. */
  109587. _debugLayer: DebugLayer;
  109588. /**
  109589. * Gets the debug layer (aka Inspector) associated with the scene
  109590. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109591. */
  109592. debugLayer: DebugLayer;
  109593. }
  109594. /**
  109595. * The debug layer (aka Inspector) is the go to tool in order to better understand
  109596. * what is happening in your scene
  109597. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109598. */
  109599. export class DebugLayer {
  109600. /**
  109601. * Define the url to get the inspector script from.
  109602. * By default it uses the babylonjs CDN.
  109603. * @ignoreNaming
  109604. */
  109605. static InspectorURL: string;
  109606. private _scene;
  109607. private BJSINSPECTOR;
  109608. private _onPropertyChangedObservable?;
  109609. /**
  109610. * Observable triggered when a property is changed through the inspector.
  109611. */
  109612. readonly onPropertyChangedObservable: any;
  109613. /**
  109614. * Instantiates a new debug layer.
  109615. * The debug layer (aka Inspector) is the go to tool in order to better understand
  109616. * what is happening in your scene
  109617. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109618. * @param scene Defines the scene to inspect
  109619. */
  109620. constructor(scene: Scene);
  109621. /** Creates the inspector window. */
  109622. private _createInspector;
  109623. /**
  109624. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  109625. * @param entity defines the entity to select
  109626. * @param lineContainerTitle defines the specific block to highlight
  109627. */
  109628. select(entity: any, lineContainerTitle?: string): void;
  109629. /** Get the inspector from bundle or global */
  109630. private _getGlobalInspector;
  109631. /**
  109632. * Get if the inspector is visible or not.
  109633. * @returns true if visible otherwise, false
  109634. */
  109635. isVisible(): boolean;
  109636. /**
  109637. * Hide the inspector and close its window.
  109638. */
  109639. hide(): void;
  109640. /**
  109641. * Launch the debugLayer.
  109642. * @param config Define the configuration of the inspector
  109643. * @return a promise fulfilled when the debug layer is visible
  109644. */
  109645. show(config?: IInspectorOptions): Promise<DebugLayer>;
  109646. }
  109647. }
  109648. declare module BABYLON {
  109649. /**
  109650. * Class containing static functions to help procedurally build meshes
  109651. */
  109652. export class BoxBuilder {
  109653. /**
  109654. * Creates a box mesh
  109655. * * The parameter `size` sets the size (float) of each box side (default 1)
  109656. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  109657. * * 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)
  109658. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109660. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109662. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  109663. * @param name defines the name of the mesh
  109664. * @param options defines the options used to create the mesh
  109665. * @param scene defines the hosting scene
  109666. * @returns the box mesh
  109667. */
  109668. static CreateBox(name: string, options: {
  109669. size?: number;
  109670. width?: number;
  109671. height?: number;
  109672. depth?: number;
  109673. faceUV?: Vector4[];
  109674. faceColors?: Color4[];
  109675. sideOrientation?: number;
  109676. frontUVs?: Vector4;
  109677. backUVs?: Vector4;
  109678. wrap?: boolean;
  109679. topBaseAt?: number;
  109680. bottomBaseAt?: number;
  109681. updatable?: boolean;
  109682. }, scene?: Nullable<Scene>): Mesh;
  109683. }
  109684. }
  109685. declare module BABYLON {
  109686. /**
  109687. * Class containing static functions to help procedurally build meshes
  109688. */
  109689. export class SphereBuilder {
  109690. /**
  109691. * Creates a sphere mesh
  109692. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  109693. * * 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`)
  109694. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  109695. * * 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
  109696. * * 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)
  109697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109698. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109700. * @param name defines the name of the mesh
  109701. * @param options defines the options used to create the mesh
  109702. * @param scene defines the hosting scene
  109703. * @returns the sphere mesh
  109704. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  109705. */
  109706. static CreateSphere(name: string, options: {
  109707. segments?: number;
  109708. diameter?: number;
  109709. diameterX?: number;
  109710. diameterY?: number;
  109711. diameterZ?: number;
  109712. arc?: number;
  109713. slice?: number;
  109714. sideOrientation?: number;
  109715. frontUVs?: Vector4;
  109716. backUVs?: Vector4;
  109717. updatable?: boolean;
  109718. }, scene?: Nullable<Scene>): Mesh;
  109719. }
  109720. }
  109721. declare module BABYLON.Debug {
  109722. /**
  109723. * Used to show the physics impostor around the specific mesh
  109724. */
  109725. export class PhysicsViewer {
  109726. /** @hidden */
  109727. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  109728. /** @hidden */
  109729. protected _meshes: Array<Nullable<AbstractMesh>>;
  109730. /** @hidden */
  109731. protected _scene: Nullable<Scene>;
  109732. /** @hidden */
  109733. protected _numMeshes: number;
  109734. /** @hidden */
  109735. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  109736. private _renderFunction;
  109737. private _utilityLayer;
  109738. private _debugBoxMesh;
  109739. private _debugSphereMesh;
  109740. private _debugCylinderMesh;
  109741. private _debugMaterial;
  109742. private _debugMeshMeshes;
  109743. /**
  109744. * Creates a new PhysicsViewer
  109745. * @param scene defines the hosting scene
  109746. */
  109747. constructor(scene: Scene);
  109748. /** @hidden */
  109749. protected _updateDebugMeshes(): void;
  109750. /**
  109751. * Renders a specified physic impostor
  109752. * @param impostor defines the impostor to render
  109753. * @param targetMesh defines the mesh represented by the impostor
  109754. * @returns the new debug mesh used to render the impostor
  109755. */
  109756. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  109757. /**
  109758. * Hides a specified physic impostor
  109759. * @param impostor defines the impostor to hide
  109760. */
  109761. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  109762. private _getDebugMaterial;
  109763. private _getDebugBoxMesh;
  109764. private _getDebugSphereMesh;
  109765. private _getDebugCylinderMesh;
  109766. private _getDebugMeshMesh;
  109767. private _getDebugMesh;
  109768. /** Releases all resources */
  109769. dispose(): void;
  109770. }
  109771. }
  109772. declare module BABYLON {
  109773. /**
  109774. * Class containing static functions to help procedurally build meshes
  109775. */
  109776. export class LinesBuilder {
  109777. /**
  109778. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  109779. * * 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
  109780. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  109781. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  109782. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  109783. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  109784. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  109785. * * 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
  109786. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  109787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109788. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  109789. * @param name defines the name of the new line system
  109790. * @param options defines the options used to create the line system
  109791. * @param scene defines the hosting scene
  109792. * @returns a new line system mesh
  109793. */
  109794. static CreateLineSystem(name: string, options: {
  109795. lines: Vector3[][];
  109796. updatable?: boolean;
  109797. instance?: Nullable<LinesMesh>;
  109798. colors?: Nullable<Color4[][]>;
  109799. useVertexAlpha?: boolean;
  109800. }, scene: Nullable<Scene>): LinesMesh;
  109801. /**
  109802. * Creates a line mesh
  109803. * 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
  109804. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109805. * * The parameter `points` is an array successive Vector3
  109806. * * 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
  109807. * * The optional parameter `colors` is an array of successive Color4, one per line point
  109808. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  109809. * * When updating an instance, remember that only point positions can change, not the number of points
  109810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109811. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  109812. * @param name defines the name of the new line system
  109813. * @param options defines the options used to create the line system
  109814. * @param scene defines the hosting scene
  109815. * @returns a new line mesh
  109816. */
  109817. static CreateLines(name: string, options: {
  109818. points: Vector3[];
  109819. updatable?: boolean;
  109820. instance?: Nullable<LinesMesh>;
  109821. colors?: Color4[];
  109822. useVertexAlpha?: boolean;
  109823. }, scene?: Nullable<Scene>): LinesMesh;
  109824. /**
  109825. * Creates a dashed line mesh
  109826. * * 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
  109827. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109828. * * The parameter `points` is an array successive Vector3
  109829. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  109830. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  109831. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109832. * * 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
  109833. * * When updating an instance, remember that only point positions can change, not the number of points
  109834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109835. * @param name defines the name of the mesh
  109836. * @param options defines the options used to create the mesh
  109837. * @param scene defines the hosting scene
  109838. * @returns the dashed line mesh
  109839. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  109840. */
  109841. static CreateDashedLines(name: string, options: {
  109842. points: Vector3[];
  109843. dashSize?: number;
  109844. gapSize?: number;
  109845. dashNb?: number;
  109846. updatable?: boolean;
  109847. instance?: LinesMesh;
  109848. }, scene?: Nullable<Scene>): LinesMesh;
  109849. }
  109850. }
  109851. declare module BABYLON {
  109852. /**
  109853. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109854. * in order to better appreciate the issue one might have.
  109855. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109856. */
  109857. export class RayHelper {
  109858. /**
  109859. * Defines the ray we are currently tryin to visualize.
  109860. */
  109861. ray: Nullable<Ray>;
  109862. private _renderPoints;
  109863. private _renderLine;
  109864. private _renderFunction;
  109865. private _scene;
  109866. private _updateToMeshFunction;
  109867. private _attachedToMesh;
  109868. private _meshSpaceDirection;
  109869. private _meshSpaceOrigin;
  109870. /**
  109871. * Helper function to create a colored helper in a scene in one line.
  109872. * @param ray Defines the ray we are currently tryin to visualize
  109873. * @param scene Defines the scene the ray is used in
  109874. * @param color Defines the color we want to see the ray in
  109875. * @returns The newly created ray helper.
  109876. */
  109877. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  109878. /**
  109879. * Instantiate a new ray helper.
  109880. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109881. * in order to better appreciate the issue one might have.
  109882. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109883. * @param ray Defines the ray we are currently tryin to visualize
  109884. */
  109885. constructor(ray: Ray);
  109886. /**
  109887. * Shows the ray we are willing to debug.
  109888. * @param scene Defines the scene the ray needs to be rendered in
  109889. * @param color Defines the color the ray needs to be rendered in
  109890. */
  109891. show(scene: Scene, color?: Color3): void;
  109892. /**
  109893. * Hides the ray we are debugging.
  109894. */
  109895. hide(): void;
  109896. private _render;
  109897. /**
  109898. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  109899. * @param mesh Defines the mesh we want the helper attached to
  109900. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  109901. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  109902. * @param length Defines the length of the ray
  109903. */
  109904. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  109905. /**
  109906. * Detach the ray helper from the mesh it has previously been attached to.
  109907. */
  109908. detachFromMesh(): void;
  109909. private _updateToMesh;
  109910. /**
  109911. * Dispose the helper and release its associated resources.
  109912. */
  109913. dispose(): void;
  109914. }
  109915. }
  109916. declare module BABYLON.Debug {
  109917. /**
  109918. * Class used to render a debug view of a given skeleton
  109919. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  109920. */
  109921. export class SkeletonViewer {
  109922. /** defines the skeleton to render */
  109923. skeleton: Skeleton;
  109924. /** defines the mesh attached to the skeleton */
  109925. mesh: AbstractMesh;
  109926. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109927. autoUpdateBonesMatrices: boolean;
  109928. /** defines the rendering group id to use with the viewer */
  109929. renderingGroupId: number;
  109930. /** Gets or sets the color used to render the skeleton */
  109931. color: Color3;
  109932. private _scene;
  109933. private _debugLines;
  109934. private _debugMesh;
  109935. private _isEnabled;
  109936. private _renderFunction;
  109937. private _utilityLayer;
  109938. /**
  109939. * Returns the mesh used to render the bones
  109940. */
  109941. readonly debugMesh: Nullable<LinesMesh>;
  109942. /**
  109943. * Creates a new SkeletonViewer
  109944. * @param skeleton defines the skeleton to render
  109945. * @param mesh defines the mesh attached to the skeleton
  109946. * @param scene defines the hosting scene
  109947. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  109948. * @param renderingGroupId defines the rendering group id to use with the viewer
  109949. */
  109950. constructor(
  109951. /** defines the skeleton to render */
  109952. skeleton: Skeleton,
  109953. /** defines the mesh attached to the skeleton */
  109954. mesh: AbstractMesh, scene: Scene,
  109955. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109956. autoUpdateBonesMatrices?: boolean,
  109957. /** defines the rendering group id to use with the viewer */
  109958. renderingGroupId?: number);
  109959. /** Gets or sets a boolean indicating if the viewer is enabled */
  109960. isEnabled: boolean;
  109961. private _getBonePosition;
  109962. private _getLinesForBonesWithLength;
  109963. private _getLinesForBonesNoLength;
  109964. /** Update the viewer to sync with current skeleton state */
  109965. update(): void;
  109966. /** Release associated resources */
  109967. dispose(): void;
  109968. }
  109969. }
  109970. declare module BABYLON {
  109971. /**
  109972. * Options to create the null engine
  109973. */
  109974. export class NullEngineOptions {
  109975. /**
  109976. * Render width (Default: 512)
  109977. */
  109978. renderWidth: number;
  109979. /**
  109980. * Render height (Default: 256)
  109981. */
  109982. renderHeight: number;
  109983. /**
  109984. * Texture size (Default: 512)
  109985. */
  109986. textureSize: number;
  109987. /**
  109988. * If delta time between frames should be constant
  109989. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109990. */
  109991. deterministicLockstep: boolean;
  109992. /**
  109993. * Maximum about of steps between frames (Default: 4)
  109994. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109995. */
  109996. lockstepMaxSteps: number;
  109997. }
  109998. /**
  109999. * The null engine class provides support for headless version of babylon.js.
  110000. * This can be used in server side scenario or for testing purposes
  110001. */
  110002. export class NullEngine extends Engine {
  110003. private _options;
  110004. /**
  110005. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  110006. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110007. * @returns true if engine is in deterministic lock step mode
  110008. */
  110009. isDeterministicLockStep(): boolean;
  110010. /**
  110011. * Gets the max steps when engine is running in deterministic lock step
  110012. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110013. * @returns the max steps
  110014. */
  110015. getLockstepMaxSteps(): number;
  110016. /**
  110017. * Gets the current hardware scaling level.
  110018. * By default the hardware scaling level is computed from the window device ratio.
  110019. * 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.
  110020. * @returns a number indicating the current hardware scaling level
  110021. */
  110022. getHardwareScalingLevel(): number;
  110023. constructor(options?: NullEngineOptions);
  110024. /**
  110025. * Creates a vertex buffer
  110026. * @param vertices the data for the vertex buffer
  110027. * @returns the new WebGL static buffer
  110028. */
  110029. createVertexBuffer(vertices: FloatArray): DataBuffer;
  110030. /**
  110031. * Creates a new index buffer
  110032. * @param indices defines the content of the index buffer
  110033. * @param updatable defines if the index buffer must be updatable
  110034. * @returns a new webGL buffer
  110035. */
  110036. createIndexBuffer(indices: IndicesArray): DataBuffer;
  110037. /**
  110038. * Clear the current render buffer or the current render target (if any is set up)
  110039. * @param color defines the color to use
  110040. * @param backBuffer defines if the back buffer must be cleared
  110041. * @param depth defines if the depth buffer must be cleared
  110042. * @param stencil defines if the stencil buffer must be cleared
  110043. */
  110044. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  110045. /**
  110046. * Gets the current render width
  110047. * @param useScreen defines if screen size must be used (or the current render target if any)
  110048. * @returns a number defining the current render width
  110049. */
  110050. getRenderWidth(useScreen?: boolean): number;
  110051. /**
  110052. * Gets the current render height
  110053. * @param useScreen defines if screen size must be used (or the current render target if any)
  110054. * @returns a number defining the current render height
  110055. */
  110056. getRenderHeight(useScreen?: boolean): number;
  110057. /**
  110058. * Set the WebGL's viewport
  110059. * @param viewport defines the viewport element to be used
  110060. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  110061. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  110062. */
  110063. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  110064. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  110065. /**
  110066. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  110067. * @param pipelineContext defines the pipeline context to use
  110068. * @param uniformsNames defines the list of uniform names
  110069. * @returns an array of webGL uniform locations
  110070. */
  110071. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  110072. /**
  110073. * Gets the lsit of active attributes for a given webGL program
  110074. * @param pipelineContext defines the pipeline context to use
  110075. * @param attributesNames defines the list of attribute names to get
  110076. * @returns an array of indices indicating the offset of each attribute
  110077. */
  110078. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  110079. /**
  110080. * Binds an effect to the webGL context
  110081. * @param effect defines the effect to bind
  110082. */
  110083. bindSamplers(effect: Effect): void;
  110084. /**
  110085. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  110086. * @param effect defines the effect to activate
  110087. */
  110088. enableEffect(effect: Effect): void;
  110089. /**
  110090. * Set various states to the webGL context
  110091. * @param culling defines backface culling state
  110092. * @param zOffset defines the value to apply to zOffset (0 by default)
  110093. * @param force defines if states must be applied even if cache is up to date
  110094. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  110095. */
  110096. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110097. /**
  110098. * Set the value of an uniform to an array of int32
  110099. * @param uniform defines the webGL uniform location where to store the value
  110100. * @param array defines the array of int32 to store
  110101. */
  110102. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  110103. /**
  110104. * Set the value of an uniform to an array of int32 (stored as vec2)
  110105. * @param uniform defines the webGL uniform location where to store the value
  110106. * @param array defines the array of int32 to store
  110107. */
  110108. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  110109. /**
  110110. * Set the value of an uniform to an array of int32 (stored as vec3)
  110111. * @param uniform defines the webGL uniform location where to store the value
  110112. * @param array defines the array of int32 to store
  110113. */
  110114. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  110115. /**
  110116. * Set the value of an uniform to an array of int32 (stored as vec4)
  110117. * @param uniform defines the webGL uniform location where to store the value
  110118. * @param array defines the array of int32 to store
  110119. */
  110120. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  110121. /**
  110122. * Set the value of an uniform to an array of float32
  110123. * @param uniform defines the webGL uniform location where to store the value
  110124. * @param array defines the array of float32 to store
  110125. */
  110126. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  110127. /**
  110128. * Set the value of an uniform to an array of float32 (stored as vec2)
  110129. * @param uniform defines the webGL uniform location where to store the value
  110130. * @param array defines the array of float32 to store
  110131. */
  110132. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  110133. /**
  110134. * Set the value of an uniform to an array of float32 (stored as vec3)
  110135. * @param uniform defines the webGL uniform location where to store the value
  110136. * @param array defines the array of float32 to store
  110137. */
  110138. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  110139. /**
  110140. * Set the value of an uniform to an array of float32 (stored as vec4)
  110141. * @param uniform defines the webGL uniform location where to store the value
  110142. * @param array defines the array of float32 to store
  110143. */
  110144. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  110145. /**
  110146. * Set the value of an uniform to an array of number
  110147. * @param uniform defines the webGL uniform location where to store the value
  110148. * @param array defines the array of number to store
  110149. */
  110150. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  110151. /**
  110152. * Set the value of an uniform to an array of number (stored as vec2)
  110153. * @param uniform defines the webGL uniform location where to store the value
  110154. * @param array defines the array of number to store
  110155. */
  110156. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  110157. /**
  110158. * Set the value of an uniform to an array of number (stored as vec3)
  110159. * @param uniform defines the webGL uniform location where to store the value
  110160. * @param array defines the array of number to store
  110161. */
  110162. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  110163. /**
  110164. * Set the value of an uniform to an array of number (stored as vec4)
  110165. * @param uniform defines the webGL uniform location where to store the value
  110166. * @param array defines the array of number to store
  110167. */
  110168. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  110169. /**
  110170. * Set the value of an uniform to an array of float32 (stored as matrices)
  110171. * @param uniform defines the webGL uniform location where to store the value
  110172. * @param matrices defines the array of float32 to store
  110173. */
  110174. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  110175. /**
  110176. * Set the value of an uniform to a matrix (3x3)
  110177. * @param uniform defines the webGL uniform location where to store the value
  110178. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  110179. */
  110180. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110181. /**
  110182. * Set the value of an uniform to a matrix (2x2)
  110183. * @param uniform defines the webGL uniform location where to store the value
  110184. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  110185. */
  110186. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110187. /**
  110188. * Set the value of an uniform to a number (float)
  110189. * @param uniform defines the webGL uniform location where to store the value
  110190. * @param value defines the float number to store
  110191. */
  110192. setFloat(uniform: WebGLUniformLocation, value: number): void;
  110193. /**
  110194. * Set the value of an uniform to a vec2
  110195. * @param uniform defines the webGL uniform location where to store the value
  110196. * @param x defines the 1st component of the value
  110197. * @param y defines the 2nd component of the value
  110198. */
  110199. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  110200. /**
  110201. * Set the value of an uniform to a vec3
  110202. * @param uniform defines the webGL uniform location where to store the value
  110203. * @param x defines the 1st component of the value
  110204. * @param y defines the 2nd component of the value
  110205. * @param z defines the 3rd component of the value
  110206. */
  110207. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  110208. /**
  110209. * Set the value of an uniform to a boolean
  110210. * @param uniform defines the webGL uniform location where to store the value
  110211. * @param bool defines the boolean to store
  110212. */
  110213. setBool(uniform: WebGLUniformLocation, bool: number): void;
  110214. /**
  110215. * Set the value of an uniform to a vec4
  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. * @param w defines the 4th component of the value
  110221. */
  110222. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  110223. /**
  110224. * Sets the current alpha mode
  110225. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  110226. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  110227. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110228. */
  110229. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  110230. /**
  110231. * Bind webGl buffers directly to the webGL context
  110232. * @param vertexBuffers defines the vertex buffer to bind
  110233. * @param indexBuffer defines the index buffer to bind
  110234. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  110235. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  110236. * @param effect defines the effect associated with the vertex buffer
  110237. */
  110238. bindBuffers(vertexBuffers: {
  110239. [key: string]: VertexBuffer;
  110240. }, indexBuffer: DataBuffer, effect: Effect): void;
  110241. /**
  110242. * Force the entire cache to be cleared
  110243. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  110244. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  110245. */
  110246. wipeCaches(bruteForce?: boolean): void;
  110247. /**
  110248. * Send a draw order
  110249. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  110250. * @param indexStart defines the starting index
  110251. * @param indexCount defines the number of index to draw
  110252. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110253. */
  110254. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  110255. /**
  110256. * Draw a list of indexed primitives
  110257. * @param fillMode defines the primitive to use
  110258. * @param indexStart defines the starting index
  110259. * @param indexCount defines the number of index to draw
  110260. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110261. */
  110262. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  110263. /**
  110264. * Draw a list of unindexed primitives
  110265. * @param fillMode defines the primitive to use
  110266. * @param verticesStart defines the index of first vertex to draw
  110267. * @param verticesCount defines the count of vertices to draw
  110268. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110269. */
  110270. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  110271. /** @hidden */
  110272. _createTexture(): WebGLTexture;
  110273. /** @hidden */
  110274. _releaseTexture(texture: InternalTexture): void;
  110275. /**
  110276. * Usually called from Texture.ts.
  110277. * Passed information to create a WebGLTexture
  110278. * @param urlArg defines a value which contains one of the following:
  110279. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  110280. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  110281. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  110282. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  110283. * @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)
  110284. * @param scene needed for loading to the correct scene
  110285. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  110286. * @param onLoad optional callback to be called upon successful completion
  110287. * @param onError optional callback to be called upon failure
  110288. * @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
  110289. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110290. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110291. * @param forcedExtension defines the extension to use to pick the right loader
  110292. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  110293. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110294. */
  110295. 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;
  110296. /**
  110297. * Creates a new render target texture
  110298. * @param size defines the size of the texture
  110299. * @param options defines the options used to create the texture
  110300. * @returns a new render target texture stored in an InternalTexture
  110301. */
  110302. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110303. /**
  110304. * Update the sampling mode of a given texture
  110305. * @param samplingMode defines the required sampling mode
  110306. * @param texture defines the texture to update
  110307. */
  110308. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110309. /**
  110310. * Binds the frame buffer to the specified texture.
  110311. * @param texture The texture to render to or null for the default canvas
  110312. * @param faceIndex The face of the texture to render to in case of cube texture
  110313. * @param requiredWidth The width of the target to render to
  110314. * @param requiredHeight The height of the target to render to
  110315. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  110316. * @param depthStencilTexture The depth stencil texture to use to render
  110317. * @param lodLevel defines le lod level to bind to the frame buffer
  110318. */
  110319. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110320. /**
  110321. * Unbind the current render target texture from the webGL context
  110322. * @param texture defines the render target texture to unbind
  110323. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  110324. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  110325. */
  110326. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110327. /**
  110328. * Creates a dynamic vertex buffer
  110329. * @param vertices the data for the dynamic vertex buffer
  110330. * @returns the new WebGL dynamic buffer
  110331. */
  110332. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  110333. /**
  110334. * Update the content of a dynamic texture
  110335. * @param texture defines the texture to update
  110336. * @param canvas defines the canvas containing the source
  110337. * @param invertY defines if data must be stored with Y axis inverted
  110338. * @param premulAlpha defines if alpha is stored as premultiplied
  110339. * @param format defines the format of the data
  110340. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  110341. */
  110342. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  110343. /**
  110344. * Gets a boolean indicating if all created effects are ready
  110345. * @returns true if all effects are ready
  110346. */
  110347. areAllEffectsReady(): boolean;
  110348. /**
  110349. * @hidden
  110350. * Get the current error code of the webGL context
  110351. * @returns the error code
  110352. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  110353. */
  110354. getError(): number;
  110355. /** @hidden */
  110356. _getUnpackAlignement(): number;
  110357. /** @hidden */
  110358. _unpackFlipY(value: boolean): void;
  110359. /**
  110360. * Update a dynamic index buffer
  110361. * @param indexBuffer defines the target index buffer
  110362. * @param indices defines the data to update
  110363. * @param offset defines the offset in the target index buffer where update should start
  110364. */
  110365. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  110366. /**
  110367. * Updates a dynamic vertex buffer.
  110368. * @param vertexBuffer the vertex buffer to update
  110369. * @param vertices the data used to update the vertex buffer
  110370. * @param byteOffset the byte offset of the data (optional)
  110371. * @param byteLength the byte length of the data (optional)
  110372. */
  110373. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  110374. /** @hidden */
  110375. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  110376. /** @hidden */
  110377. _bindTexture(channel: number, texture: InternalTexture): void;
  110378. protected _deleteBuffer(buffer: WebGLBuffer): void;
  110379. /**
  110380. * 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
  110381. */
  110382. releaseEffects(): void;
  110383. displayLoadingUI(): void;
  110384. hideLoadingUI(): void;
  110385. /** @hidden */
  110386. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110387. /** @hidden */
  110388. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110389. /** @hidden */
  110390. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110391. /** @hidden */
  110392. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110393. }
  110394. }
  110395. declare module BABYLON {
  110396. /** @hidden */
  110397. export class _OcclusionDataStorage {
  110398. /** @hidden */
  110399. occlusionInternalRetryCounter: number;
  110400. /** @hidden */
  110401. isOcclusionQueryInProgress: boolean;
  110402. /** @hidden */
  110403. isOccluded: boolean;
  110404. /** @hidden */
  110405. occlusionRetryCount: number;
  110406. /** @hidden */
  110407. occlusionType: number;
  110408. /** @hidden */
  110409. occlusionQueryAlgorithmType: number;
  110410. }
  110411. interface Engine {
  110412. /**
  110413. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  110414. * @return the new query
  110415. */
  110416. createQuery(): WebGLQuery;
  110417. /**
  110418. * Delete and release a webGL query
  110419. * @param query defines the query to delete
  110420. * @return the current engine
  110421. */
  110422. deleteQuery(query: WebGLQuery): Engine;
  110423. /**
  110424. * Check if a given query has resolved and got its value
  110425. * @param query defines the query to check
  110426. * @returns true if the query got its value
  110427. */
  110428. isQueryResultAvailable(query: WebGLQuery): boolean;
  110429. /**
  110430. * Gets the value of a given query
  110431. * @param query defines the query to check
  110432. * @returns the value of the query
  110433. */
  110434. getQueryResult(query: WebGLQuery): number;
  110435. /**
  110436. * Initiates an occlusion query
  110437. * @param algorithmType defines the algorithm to use
  110438. * @param query defines the query to use
  110439. * @returns the current engine
  110440. * @see http://doc.babylonjs.com/features/occlusionquery
  110441. */
  110442. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  110443. /**
  110444. * Ends an occlusion query
  110445. * @see http://doc.babylonjs.com/features/occlusionquery
  110446. * @param algorithmType defines the algorithm to use
  110447. * @returns the current engine
  110448. */
  110449. endOcclusionQuery(algorithmType: number): Engine;
  110450. /**
  110451. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  110452. * Please note that only one query can be issued at a time
  110453. * @returns a time token used to track the time span
  110454. */
  110455. startTimeQuery(): Nullable<_TimeToken>;
  110456. /**
  110457. * Ends a time query
  110458. * @param token defines the token used to measure the time span
  110459. * @returns the time spent (in ns)
  110460. */
  110461. endTimeQuery(token: _TimeToken): int;
  110462. /** @hidden */
  110463. _currentNonTimestampToken: Nullable<_TimeToken>;
  110464. /** @hidden */
  110465. _createTimeQuery(): WebGLQuery;
  110466. /** @hidden */
  110467. _deleteTimeQuery(query: WebGLQuery): void;
  110468. /** @hidden */
  110469. _getGlAlgorithmType(algorithmType: number): number;
  110470. /** @hidden */
  110471. _getTimeQueryResult(query: WebGLQuery): any;
  110472. /** @hidden */
  110473. _getTimeQueryAvailability(query: WebGLQuery): any;
  110474. }
  110475. interface AbstractMesh {
  110476. /**
  110477. * Backing filed
  110478. * @hidden
  110479. */
  110480. __occlusionDataStorage: _OcclusionDataStorage;
  110481. /**
  110482. * Access property
  110483. * @hidden
  110484. */
  110485. _occlusionDataStorage: _OcclusionDataStorage;
  110486. /**
  110487. * 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.
  110488. * The default value is -1 which means don't break the query and wait till the result
  110489. * @see http://doc.babylonjs.com/features/occlusionquery
  110490. */
  110491. occlusionRetryCount: number;
  110492. /**
  110493. * 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:
  110494. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  110495. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  110496. * * 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.
  110497. * @see http://doc.babylonjs.com/features/occlusionquery
  110498. */
  110499. occlusionType: number;
  110500. /**
  110501. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  110502. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  110503. * * 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.
  110504. * @see http://doc.babylonjs.com/features/occlusionquery
  110505. */
  110506. occlusionQueryAlgorithmType: number;
  110507. /**
  110508. * 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
  110509. * @see http://doc.babylonjs.com/features/occlusionquery
  110510. */
  110511. isOccluded: boolean;
  110512. /**
  110513. * Flag to check the progress status of the query
  110514. * @see http://doc.babylonjs.com/features/occlusionquery
  110515. */
  110516. isOcclusionQueryInProgress: boolean;
  110517. }
  110518. }
  110519. declare module BABYLON {
  110520. /** @hidden */
  110521. export var _forceTransformFeedbackToBundle: boolean;
  110522. interface Engine {
  110523. /**
  110524. * Creates a webGL transform feedback object
  110525. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  110526. * @returns the webGL transform feedback object
  110527. */
  110528. createTransformFeedback(): WebGLTransformFeedback;
  110529. /**
  110530. * Delete a webGL transform feedback object
  110531. * @param value defines the webGL transform feedback object to delete
  110532. */
  110533. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  110534. /**
  110535. * Bind a webGL transform feedback object to the webgl context
  110536. * @param value defines the webGL transform feedback object to bind
  110537. */
  110538. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  110539. /**
  110540. * Begins a transform feedback operation
  110541. * @param usePoints defines if points or triangles must be used
  110542. */
  110543. beginTransformFeedback(usePoints: boolean): void;
  110544. /**
  110545. * Ends a transform feedback operation
  110546. */
  110547. endTransformFeedback(): void;
  110548. /**
  110549. * Specify the varyings to use with transform feedback
  110550. * @param program defines the associated webGL program
  110551. * @param value defines the list of strings representing the varying names
  110552. */
  110553. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  110554. /**
  110555. * Bind a webGL buffer for a transform feedback operation
  110556. * @param value defines the webGL buffer to bind
  110557. */
  110558. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  110559. }
  110560. }
  110561. declare module BABYLON {
  110562. /**
  110563. * Creation options of the multi render target texture.
  110564. */
  110565. export interface IMultiRenderTargetOptions {
  110566. /**
  110567. * Define if the texture needs to create mip maps after render.
  110568. */
  110569. generateMipMaps?: boolean;
  110570. /**
  110571. * Define the types of all the draw buffers we want to create
  110572. */
  110573. types?: number[];
  110574. /**
  110575. * Define the sampling modes of all the draw buffers we want to create
  110576. */
  110577. samplingModes?: number[];
  110578. /**
  110579. * Define if a depth buffer is required
  110580. */
  110581. generateDepthBuffer?: boolean;
  110582. /**
  110583. * Define if a stencil buffer is required
  110584. */
  110585. generateStencilBuffer?: boolean;
  110586. /**
  110587. * Define if a depth texture is required instead of a depth buffer
  110588. */
  110589. generateDepthTexture?: boolean;
  110590. /**
  110591. * Define the number of desired draw buffers
  110592. */
  110593. textureCount?: number;
  110594. /**
  110595. * Define if aspect ratio should be adapted to the texture or stay the scene one
  110596. */
  110597. doNotChangeAspectRatio?: boolean;
  110598. /**
  110599. * Define the default type of the buffers we are creating
  110600. */
  110601. defaultType?: number;
  110602. }
  110603. /**
  110604. * A multi render target, like a render target provides the ability to render to a texture.
  110605. * Unlike the render target, it can render to several draw buffers in one draw.
  110606. * This is specially interesting in deferred rendering or for any effects requiring more than
  110607. * just one color from a single pass.
  110608. */
  110609. export class MultiRenderTarget extends RenderTargetTexture {
  110610. private _internalTextures;
  110611. private _textures;
  110612. private _multiRenderTargetOptions;
  110613. /**
  110614. * Get if draw buffers are currently supported by the used hardware and browser.
  110615. */
  110616. readonly isSupported: boolean;
  110617. /**
  110618. * Get the list of textures generated by the multi render target.
  110619. */
  110620. readonly textures: Texture[];
  110621. /**
  110622. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  110623. */
  110624. readonly depthTexture: Texture;
  110625. /**
  110626. * Set the wrapping mode on U of all the textures we are rendering to.
  110627. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  110628. */
  110629. wrapU: number;
  110630. /**
  110631. * Set the wrapping mode on V of all the textures we are rendering to.
  110632. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  110633. */
  110634. wrapV: number;
  110635. /**
  110636. * Instantiate a new multi render target texture.
  110637. * A multi render target, like a render target provides the ability to render to a texture.
  110638. * Unlike the render target, it can render to several draw buffers in one draw.
  110639. * This is specially interesting in deferred rendering or for any effects requiring more than
  110640. * just one color from a single pass.
  110641. * @param name Define the name of the texture
  110642. * @param size Define the size of the buffers to render to
  110643. * @param count Define the number of target we are rendering into
  110644. * @param scene Define the scene the texture belongs to
  110645. * @param options Define the options used to create the multi render target
  110646. */
  110647. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  110648. /** @hidden */
  110649. _rebuild(): void;
  110650. private _createInternalTextures;
  110651. private _createTextures;
  110652. /**
  110653. * Define the number of samples used if MSAA is enabled.
  110654. */
  110655. samples: number;
  110656. /**
  110657. * Resize all the textures in the multi render target.
  110658. * Be carrefull as it will recreate all the data in the new texture.
  110659. * @param size Define the new size
  110660. */
  110661. resize(size: any): void;
  110662. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  110663. /**
  110664. * Dispose the render targets and their associated resources
  110665. */
  110666. dispose(): void;
  110667. /**
  110668. * Release all the underlying texture used as draw buffers.
  110669. */
  110670. releaseInternalTextures(): void;
  110671. }
  110672. }
  110673. declare module BABYLON {
  110674. interface ThinEngine {
  110675. /**
  110676. * Unbind a list of render target textures from the webGL context
  110677. * This is used only when drawBuffer extension or webGL2 are active
  110678. * @param textures defines the render target textures to unbind
  110679. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  110680. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  110681. */
  110682. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  110683. /**
  110684. * Create a multi render target texture
  110685. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  110686. * @param size defines the size of the texture
  110687. * @param options defines the creation options
  110688. * @returns the cube texture as an InternalTexture
  110689. */
  110690. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  110691. /**
  110692. * Update the sample count for a given multiple render target texture
  110693. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  110694. * @param textures defines the textures to update
  110695. * @param samples defines the sample count to set
  110696. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  110697. */
  110698. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  110699. }
  110700. }
  110701. declare module BABYLON {
  110702. /** @hidden */
  110703. export var rgbdEncodePixelShader: {
  110704. name: string;
  110705. shader: string;
  110706. };
  110707. }
  110708. declare module BABYLON {
  110709. /** @hidden */
  110710. export var rgbdDecodePixelShader: {
  110711. name: string;
  110712. shader: string;
  110713. };
  110714. }
  110715. declare module BABYLON {
  110716. /**
  110717. * Raw texture data and descriptor sufficient for WebGL texture upload
  110718. */
  110719. export interface EnvironmentTextureInfo {
  110720. /**
  110721. * Version of the environment map
  110722. */
  110723. version: number;
  110724. /**
  110725. * Width of image
  110726. */
  110727. width: number;
  110728. /**
  110729. * Irradiance information stored in the file.
  110730. */
  110731. irradiance: any;
  110732. /**
  110733. * Specular information stored in the file.
  110734. */
  110735. specular: any;
  110736. }
  110737. /**
  110738. * Defines One Image in the file. It requires only the position in the file
  110739. * as well as the length.
  110740. */
  110741. interface BufferImageData {
  110742. /**
  110743. * Length of the image data.
  110744. */
  110745. length: number;
  110746. /**
  110747. * Position of the data from the null terminator delimiting the end of the JSON.
  110748. */
  110749. position: number;
  110750. }
  110751. /**
  110752. * Defines the specular data enclosed in the file.
  110753. * This corresponds to the version 1 of the data.
  110754. */
  110755. export interface EnvironmentTextureSpecularInfoV1 {
  110756. /**
  110757. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  110758. */
  110759. specularDataPosition?: number;
  110760. /**
  110761. * This contains all the images data needed to reconstruct the cubemap.
  110762. */
  110763. mipmaps: Array<BufferImageData>;
  110764. /**
  110765. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  110766. */
  110767. lodGenerationScale: number;
  110768. }
  110769. /**
  110770. * Sets of helpers addressing the serialization and deserialization of environment texture
  110771. * stored in a BabylonJS env file.
  110772. * Those files are usually stored as .env files.
  110773. */
  110774. export class EnvironmentTextureTools {
  110775. /**
  110776. * Magic number identifying the env file.
  110777. */
  110778. private static _MagicBytes;
  110779. /**
  110780. * Gets the environment info from an env file.
  110781. * @param data The array buffer containing the .env bytes.
  110782. * @returns the environment file info (the json header) if successfully parsed.
  110783. */
  110784. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  110785. /**
  110786. * Creates an environment texture from a loaded cube texture.
  110787. * @param texture defines the cube texture to convert in env file
  110788. * @return a promise containing the environment data if succesfull.
  110789. */
  110790. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  110791. /**
  110792. * Creates a JSON representation of the spherical data.
  110793. * @param texture defines the texture containing the polynomials
  110794. * @return the JSON representation of the spherical info
  110795. */
  110796. private static _CreateEnvTextureIrradiance;
  110797. /**
  110798. * Creates the ArrayBufferViews used for initializing environment texture image data.
  110799. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  110800. * @param info parameters that determine what views will be created for accessing the underlying buffer
  110801. * @return the views described by info providing access to the underlying buffer
  110802. */
  110803. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  110804. /**
  110805. * Uploads the texture info contained in the env file to the GPU.
  110806. * @param texture defines the internal texture to upload to
  110807. * @param arrayBuffer defines the buffer cotaining the data to load
  110808. * @param info defines the texture info retrieved through the GetEnvInfo method
  110809. * @returns a promise
  110810. */
  110811. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  110812. /**
  110813. * Uploads the levels of image data to the GPU.
  110814. * @param texture defines the internal texture to upload to
  110815. * @param imageData defines the array buffer views of image data [mipmap][face]
  110816. * @returns a promise
  110817. */
  110818. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  110819. /**
  110820. * Uploads spherical polynomials information to the texture.
  110821. * @param texture defines the texture we are trying to upload the information to
  110822. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  110823. */
  110824. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  110825. /** @hidden */
  110826. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  110827. }
  110828. }
  110829. declare module BABYLON {
  110830. /**
  110831. * Contains position and normal vectors for a vertex
  110832. */
  110833. export class PositionNormalVertex {
  110834. /** the position of the vertex (defaut: 0,0,0) */
  110835. position: Vector3;
  110836. /** the normal of the vertex (defaut: 0,1,0) */
  110837. normal: Vector3;
  110838. /**
  110839. * Creates a PositionNormalVertex
  110840. * @param position the position of the vertex (defaut: 0,0,0)
  110841. * @param normal the normal of the vertex (defaut: 0,1,0)
  110842. */
  110843. constructor(
  110844. /** the position of the vertex (defaut: 0,0,0) */
  110845. position?: Vector3,
  110846. /** the normal of the vertex (defaut: 0,1,0) */
  110847. normal?: Vector3);
  110848. /**
  110849. * Clones the PositionNormalVertex
  110850. * @returns the cloned PositionNormalVertex
  110851. */
  110852. clone(): PositionNormalVertex;
  110853. }
  110854. /**
  110855. * Contains position, normal and uv vectors for a vertex
  110856. */
  110857. export class PositionNormalTextureVertex {
  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. /** the uv of the vertex (default: 0,0) */
  110863. uv: Vector2;
  110864. /**
  110865. * Creates a PositionNormalTextureVertex
  110866. * @param position the position of the vertex (defaut: 0,0,0)
  110867. * @param normal the normal of the vertex (defaut: 0,1,0)
  110868. * @param uv the uv of the vertex (default: 0,0)
  110869. */
  110870. constructor(
  110871. /** the position of the vertex (defaut: 0,0,0) */
  110872. position?: Vector3,
  110873. /** the normal of the vertex (defaut: 0,1,0) */
  110874. normal?: Vector3,
  110875. /** the uv of the vertex (default: 0,0) */
  110876. uv?: Vector2);
  110877. /**
  110878. * Clones the PositionNormalTextureVertex
  110879. * @returns the cloned PositionNormalTextureVertex
  110880. */
  110881. clone(): PositionNormalTextureVertex;
  110882. }
  110883. }
  110884. declare module BABYLON {
  110885. /** @hidden */
  110886. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  110887. private _genericAttributeLocation;
  110888. private _varyingLocationCount;
  110889. private _varyingLocationMap;
  110890. private _replacements;
  110891. private _textureCount;
  110892. private _uniforms;
  110893. lineProcessor(line: string): string;
  110894. attributeProcessor(attribute: string): string;
  110895. varyingProcessor(varying: string, isFragment: boolean): string;
  110896. uniformProcessor(uniform: string): string;
  110897. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  110898. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  110899. }
  110900. }
  110901. declare module BABYLON {
  110902. /**
  110903. * Container for accessors for natively-stored mesh data buffers.
  110904. */
  110905. class NativeDataBuffer extends DataBuffer {
  110906. /**
  110907. * Accessor value used to identify/retrieve a natively-stored index buffer.
  110908. */
  110909. nativeIndexBuffer?: any;
  110910. /**
  110911. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  110912. */
  110913. nativeVertexBuffer?: any;
  110914. }
  110915. /** @hidden */
  110916. export class NativeEngine extends Engine {
  110917. private readonly _native;
  110918. getHardwareScalingLevel(): number;
  110919. constructor();
  110920. /**
  110921. * Can be used to override the current requestAnimationFrame requester.
  110922. * @hidden
  110923. */
  110924. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  110925. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  110926. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  110927. createVertexBuffer(data: DataArray): NativeDataBuffer;
  110928. recordVertexArrayObject(vertexBuffers: {
  110929. [key: string]: VertexBuffer;
  110930. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  110931. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  110932. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  110933. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  110934. /**
  110935. * Draw a list of indexed primitives
  110936. * @param fillMode defines the primitive to use
  110937. * @param indexStart defines the starting index
  110938. * @param indexCount defines the number of index to draw
  110939. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110940. */
  110941. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  110942. /**
  110943. * Draw a list of unindexed primitives
  110944. * @param fillMode defines the primitive to use
  110945. * @param verticesStart defines the index of first vertex to draw
  110946. * @param verticesCount defines the count of vertices to draw
  110947. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110948. */
  110949. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  110950. createPipelineContext(): IPipelineContext;
  110951. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  110952. /** @hidden */
  110953. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  110954. /** @hidden */
  110955. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  110956. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  110957. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  110958. protected _setProgram(program: WebGLProgram): void;
  110959. _releaseEffect(effect: Effect): void;
  110960. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  110961. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  110962. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  110963. bindSamplers(effect: Effect): void;
  110964. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  110965. getRenderWidth(useScreen?: boolean): number;
  110966. getRenderHeight(useScreen?: boolean): number;
  110967. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  110968. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110969. /**
  110970. * Set the z offset to apply to current rendering
  110971. * @param value defines the offset to apply
  110972. */
  110973. setZOffset(value: number): void;
  110974. /**
  110975. * Gets the current value of the zOffset
  110976. * @returns the current zOffset state
  110977. */
  110978. getZOffset(): number;
  110979. /**
  110980. * Enable or disable depth buffering
  110981. * @param enable defines the state to set
  110982. */
  110983. setDepthBuffer(enable: boolean): void;
  110984. /**
  110985. * Gets a boolean indicating if depth writing is enabled
  110986. * @returns the current depth writing state
  110987. */
  110988. getDepthWrite(): boolean;
  110989. /**
  110990. * Enable or disable depth writing
  110991. * @param enable defines the state to set
  110992. */
  110993. setDepthWrite(enable: boolean): void;
  110994. /**
  110995. * Enable or disable color writing
  110996. * @param enable defines the state to set
  110997. */
  110998. setColorWrite(enable: boolean): void;
  110999. /**
  111000. * Gets a boolean indicating if color writing is enabled
  111001. * @returns the current color writing state
  111002. */
  111003. getColorWrite(): boolean;
  111004. /**
  111005. * Sets alpha constants used by some alpha blending modes
  111006. * @param r defines the red component
  111007. * @param g defines the green component
  111008. * @param b defines the blue component
  111009. * @param a defines the alpha component
  111010. */
  111011. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  111012. /**
  111013. * Sets the current alpha mode
  111014. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  111015. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111016. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111017. */
  111018. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111019. /**
  111020. * Gets the current alpha mode
  111021. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111022. * @returns the current alpha mode
  111023. */
  111024. getAlphaMode(): number;
  111025. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111026. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111027. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111028. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111029. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111030. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111031. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111032. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111033. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111034. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111035. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111036. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111037. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111038. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111039. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111040. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111041. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111042. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111043. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111044. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111045. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  111046. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  111047. wipeCaches(bruteForce?: boolean): void;
  111048. _createTexture(): WebGLTexture;
  111049. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  111050. /**
  111051. * Usually called from BABYLON.Texture.ts.
  111052. * Passed information to create a WebGLTexture
  111053. * @param urlArg defines a value which contains one of the following:
  111054. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111055. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111056. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111057. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111058. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  111059. * @param scene needed for loading to the correct scene
  111060. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  111061. * @param onLoad optional callback to be called upon successful completion
  111062. * @param onError optional callback to be called upon failure
  111063. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  111064. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111065. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111066. * @param forcedExtension defines the extension to use to pick the right loader
  111067. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111068. */
  111069. 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;
  111070. /**
  111071. * Creates a cube texture
  111072. * @param rootUrl defines the url where the files to load is located
  111073. * @param scene defines the current scene
  111074. * @param files defines the list of files to load (1 per face)
  111075. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  111076. * @param onLoad defines an optional callback raised when the texture is loaded
  111077. * @param onError defines an optional callback raised if there is an issue to load the texture
  111078. * @param format defines the format of the data
  111079. * @param forcedExtension defines the extension to use to pick the right loader
  111080. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  111081. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  111082. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  111083. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  111084. * @returns the cube texture as an InternalTexture
  111085. */
  111086. 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;
  111087. private _getSamplingFilter;
  111088. private static _GetNativeTextureFormat;
  111089. createRenderTargetTexture(size: number | {
  111090. width: number;
  111091. height: number;
  111092. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111093. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111094. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111095. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111096. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  111097. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  111098. /**
  111099. * Updates a dynamic vertex buffer.
  111100. * @param vertexBuffer the vertex buffer to update
  111101. * @param data the data used to update the vertex buffer
  111102. * @param byteOffset the byte offset of the data (optional)
  111103. * @param byteLength the byte length of the data (optional)
  111104. */
  111105. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  111106. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  111107. private _updateAnisotropicLevel;
  111108. private _getAddressMode;
  111109. /** @hidden */
  111110. _bindTexture(channel: number, texture: InternalTexture): void;
  111111. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  111112. releaseEffects(): void;
  111113. /** @hidden */
  111114. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111115. /** @hidden */
  111116. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111117. /** @hidden */
  111118. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111119. /** @hidden */
  111120. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  111121. }
  111122. }
  111123. declare module BABYLON {
  111124. /**
  111125. * Gather the list of clipboard event types as constants.
  111126. */
  111127. export class ClipboardEventTypes {
  111128. /**
  111129. * The clipboard event is fired when a copy command is active (pressed).
  111130. */
  111131. static readonly COPY: number;
  111132. /**
  111133. * The clipboard event is fired when a cut command is active (pressed).
  111134. */
  111135. static readonly CUT: number;
  111136. /**
  111137. * The clipboard event is fired when a paste command is active (pressed).
  111138. */
  111139. static readonly PASTE: number;
  111140. }
  111141. /**
  111142. * This class is used to store clipboard related info for the onClipboardObservable event.
  111143. */
  111144. export class ClipboardInfo {
  111145. /**
  111146. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111147. */
  111148. type: number;
  111149. /**
  111150. * Defines the related dom event
  111151. */
  111152. event: ClipboardEvent;
  111153. /**
  111154. *Creates an instance of ClipboardInfo.
  111155. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  111156. * @param event Defines the related dom event
  111157. */
  111158. constructor(
  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. * Get the clipboard event's type from the keycode.
  111169. * @param keyCode Defines the keyCode for the current keyboard event.
  111170. * @return {number}
  111171. */
  111172. static GetTypeFromCharacter(keyCode: number): number;
  111173. }
  111174. }
  111175. declare module BABYLON {
  111176. /**
  111177. * Google Daydream controller
  111178. */
  111179. export class DaydreamController extends WebVRController {
  111180. /**
  111181. * Base Url for the controller model.
  111182. */
  111183. static MODEL_BASE_URL: string;
  111184. /**
  111185. * File name for the controller model.
  111186. */
  111187. static MODEL_FILENAME: string;
  111188. /**
  111189. * Gamepad Id prefix used to identify Daydream Controller.
  111190. */
  111191. static readonly GAMEPAD_ID_PREFIX: string;
  111192. /**
  111193. * Creates a new DaydreamController from a gamepad
  111194. * @param vrGamepad the gamepad that the controller should be created from
  111195. */
  111196. constructor(vrGamepad: any);
  111197. /**
  111198. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111199. * @param scene scene in which to add meshes
  111200. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111201. */
  111202. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111203. /**
  111204. * Called once for each button that changed state since the last frame
  111205. * @param buttonIdx Which button index changed
  111206. * @param state New state of the button
  111207. * @param changes Which properties on the state changed since last frame
  111208. */
  111209. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111210. }
  111211. }
  111212. declare module BABYLON {
  111213. /**
  111214. * Gear VR Controller
  111215. */
  111216. export class GearVRController extends WebVRController {
  111217. /**
  111218. * Base Url for the controller model.
  111219. */
  111220. static MODEL_BASE_URL: string;
  111221. /**
  111222. * File name for the controller model.
  111223. */
  111224. static MODEL_FILENAME: string;
  111225. /**
  111226. * Gamepad Id prefix used to identify this controller.
  111227. */
  111228. static readonly GAMEPAD_ID_PREFIX: string;
  111229. private readonly _buttonIndexToObservableNameMap;
  111230. /**
  111231. * Creates a new GearVRController from a gamepad
  111232. * @param vrGamepad the gamepad that the controller should be created from
  111233. */
  111234. constructor(vrGamepad: any);
  111235. /**
  111236. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111237. * @param scene scene in which to add meshes
  111238. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111239. */
  111240. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111241. /**
  111242. * Called once for each button that changed state since the last frame
  111243. * @param buttonIdx Which button index changed
  111244. * @param state New state of the button
  111245. * @param changes Which properties on the state changed since last frame
  111246. */
  111247. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111248. }
  111249. }
  111250. declare module BABYLON {
  111251. /**
  111252. * Class containing static functions to help procedurally build meshes
  111253. */
  111254. export class PolyhedronBuilder {
  111255. /**
  111256. * Creates a polyhedron mesh
  111257. * * 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
  111258. * * The parameter `size` (positive float, default 1) sets the polygon size
  111259. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  111260. * * 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`
  111261. * * 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
  111262. * * 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)`)
  111263. * * 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
  111264. * * 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
  111265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111266. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111268. * @param name defines the name of the mesh
  111269. * @param options defines the options used to create the mesh
  111270. * @param scene defines the hosting scene
  111271. * @returns the polyhedron mesh
  111272. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  111273. */
  111274. static CreatePolyhedron(name: string, options: {
  111275. type?: number;
  111276. size?: number;
  111277. sizeX?: number;
  111278. sizeY?: number;
  111279. sizeZ?: number;
  111280. custom?: any;
  111281. faceUV?: Vector4[];
  111282. faceColors?: Color4[];
  111283. flat?: boolean;
  111284. updatable?: boolean;
  111285. sideOrientation?: number;
  111286. frontUVs?: Vector4;
  111287. backUVs?: Vector4;
  111288. }, scene?: Nullable<Scene>): Mesh;
  111289. }
  111290. }
  111291. declare module BABYLON {
  111292. /**
  111293. * Gizmo that enables scaling a mesh along 3 axis
  111294. */
  111295. export class ScaleGizmo extends Gizmo {
  111296. /**
  111297. * Internal gizmo used for interactions on the x axis
  111298. */
  111299. xGizmo: AxisScaleGizmo;
  111300. /**
  111301. * Internal gizmo used for interactions on the y axis
  111302. */
  111303. yGizmo: AxisScaleGizmo;
  111304. /**
  111305. * Internal gizmo used for interactions on the z axis
  111306. */
  111307. zGizmo: AxisScaleGizmo;
  111308. /**
  111309. * Internal gizmo used to scale all axis equally
  111310. */
  111311. uniformScaleGizmo: AxisScaleGizmo;
  111312. private _meshAttached;
  111313. private _updateGizmoRotationToMatchAttachedMesh;
  111314. private _snapDistance;
  111315. private _scaleRatio;
  111316. private _uniformScalingMesh;
  111317. private _octahedron;
  111318. /** Fires an event when any of it's sub gizmos are dragged */
  111319. onDragStartObservable: Observable<unknown>;
  111320. /** Fires an event when any of it's sub gizmos are released from dragging */
  111321. onDragEndObservable: Observable<unknown>;
  111322. attachedMesh: Nullable<AbstractMesh>;
  111323. /**
  111324. * Creates a ScaleGizmo
  111325. * @param gizmoLayer The utility layer the gizmo will be added to
  111326. */
  111327. constructor(gizmoLayer?: UtilityLayerRenderer);
  111328. updateGizmoRotationToMatchAttachedMesh: boolean;
  111329. /**
  111330. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111331. */
  111332. snapDistance: number;
  111333. /**
  111334. * Ratio for the scale of the gizmo (Default: 1)
  111335. */
  111336. scaleRatio: number;
  111337. /**
  111338. * Disposes of the gizmo
  111339. */
  111340. dispose(): void;
  111341. }
  111342. }
  111343. declare module BABYLON {
  111344. /**
  111345. * Single axis scale gizmo
  111346. */
  111347. export class AxisScaleGizmo extends Gizmo {
  111348. /**
  111349. * Drag behavior responsible for the gizmos dragging interactions
  111350. */
  111351. dragBehavior: PointerDragBehavior;
  111352. private _pointerObserver;
  111353. /**
  111354. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111355. */
  111356. snapDistance: number;
  111357. /**
  111358. * Event that fires each time the gizmo snaps to a new location.
  111359. * * snapDistance is the the change in distance
  111360. */
  111361. onSnapObservable: Observable<{
  111362. snapDistance: number;
  111363. }>;
  111364. /**
  111365. * If the scaling operation should be done on all axis (default: false)
  111366. */
  111367. uniformScaling: boolean;
  111368. private _isEnabled;
  111369. private _parent;
  111370. private _arrow;
  111371. private _coloredMaterial;
  111372. private _hoverMaterial;
  111373. /**
  111374. * Creates an AxisScaleGizmo
  111375. * @param gizmoLayer The utility layer the gizmo will be added to
  111376. * @param dragAxis The axis which the gizmo will be able to scale on
  111377. * @param color The color of the gizmo
  111378. */
  111379. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  111380. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111381. /**
  111382. * If the gizmo is enabled
  111383. */
  111384. isEnabled: boolean;
  111385. /**
  111386. * Disposes of the gizmo
  111387. */
  111388. dispose(): void;
  111389. /**
  111390. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111391. * @param mesh The mesh to replace the default mesh of the gizmo
  111392. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  111393. */
  111394. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  111395. }
  111396. }
  111397. declare module BABYLON {
  111398. /**
  111399. * Bounding box gizmo
  111400. */
  111401. export class BoundingBoxGizmo extends Gizmo {
  111402. private _lineBoundingBox;
  111403. private _rotateSpheresParent;
  111404. private _scaleBoxesParent;
  111405. private _boundingDimensions;
  111406. private _renderObserver;
  111407. private _pointerObserver;
  111408. private _scaleDragSpeed;
  111409. private _tmpQuaternion;
  111410. private _tmpVector;
  111411. private _tmpRotationMatrix;
  111412. /**
  111413. * 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)
  111414. */
  111415. ignoreChildren: boolean;
  111416. /**
  111417. * 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)
  111418. */
  111419. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  111420. /**
  111421. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  111422. */
  111423. rotationSphereSize: number;
  111424. /**
  111425. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  111426. */
  111427. scaleBoxSize: number;
  111428. /**
  111429. * 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)
  111430. */
  111431. fixedDragMeshScreenSize: boolean;
  111432. /**
  111433. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  111434. */
  111435. fixedDragMeshScreenSizeDistanceFactor: number;
  111436. /**
  111437. * Fired when a rotation sphere or scale box is dragged
  111438. */
  111439. onDragStartObservable: Observable<{}>;
  111440. /**
  111441. * Fired when a scale box is dragged
  111442. */
  111443. onScaleBoxDragObservable: Observable<{}>;
  111444. /**
  111445. * Fired when a scale box drag is ended
  111446. */
  111447. onScaleBoxDragEndObservable: Observable<{}>;
  111448. /**
  111449. * Fired when a rotation sphere is dragged
  111450. */
  111451. onRotationSphereDragObservable: Observable<{}>;
  111452. /**
  111453. * Fired when a rotation sphere drag is ended
  111454. */
  111455. onRotationSphereDragEndObservable: Observable<{}>;
  111456. /**
  111457. * 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)
  111458. */
  111459. scalePivot: Nullable<Vector3>;
  111460. /**
  111461. * Mesh used as a pivot to rotate the attached mesh
  111462. */
  111463. private _anchorMesh;
  111464. private _existingMeshScale;
  111465. private _dragMesh;
  111466. private pointerDragBehavior;
  111467. private coloredMaterial;
  111468. private hoverColoredMaterial;
  111469. /**
  111470. * Sets the color of the bounding box gizmo
  111471. * @param color the color to set
  111472. */
  111473. setColor(color: Color3): void;
  111474. /**
  111475. * Creates an BoundingBoxGizmo
  111476. * @param gizmoLayer The utility layer the gizmo will be added to
  111477. * @param color The color of the gizmo
  111478. */
  111479. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  111480. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111481. private _selectNode;
  111482. /**
  111483. * Updates the bounding box information for the Gizmo
  111484. */
  111485. updateBoundingBox(): void;
  111486. private _updateRotationSpheres;
  111487. private _updateScaleBoxes;
  111488. /**
  111489. * Enables rotation on the specified axis and disables rotation on the others
  111490. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  111491. */
  111492. setEnabledRotationAxis(axis: string): void;
  111493. /**
  111494. * Enables/disables scaling
  111495. * @param enable if scaling should be enabled
  111496. */
  111497. setEnabledScaling(enable: boolean): void;
  111498. private _updateDummy;
  111499. /**
  111500. * Enables a pointer drag behavior on the bounding box of the gizmo
  111501. */
  111502. enableDragBehavior(): void;
  111503. /**
  111504. * Disposes of the gizmo
  111505. */
  111506. dispose(): void;
  111507. /**
  111508. * 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)
  111509. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  111510. * @returns the bounding box mesh with the passed in mesh as a child
  111511. */
  111512. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  111513. /**
  111514. * CustomMeshes are not supported by this gizmo
  111515. * @param mesh The mesh to replace the default mesh of the gizmo
  111516. */
  111517. setCustomMesh(mesh: Mesh): void;
  111518. }
  111519. }
  111520. declare module BABYLON {
  111521. /**
  111522. * Single plane rotation gizmo
  111523. */
  111524. export class PlaneRotationGizmo extends Gizmo {
  111525. /**
  111526. * Drag behavior responsible for the gizmos dragging interactions
  111527. */
  111528. dragBehavior: PointerDragBehavior;
  111529. private _pointerObserver;
  111530. /**
  111531. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  111532. */
  111533. snapDistance: number;
  111534. /**
  111535. * Event that fires each time the gizmo snaps to a new location.
  111536. * * snapDistance is the the change in distance
  111537. */
  111538. onSnapObservable: Observable<{
  111539. snapDistance: number;
  111540. }>;
  111541. private _isEnabled;
  111542. private _parent;
  111543. /**
  111544. * Creates a PlaneRotationGizmo
  111545. * @param gizmoLayer The utility layer the gizmo will be added to
  111546. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  111547. * @param color The color of the gizmo
  111548. * @param tessellation Amount of tessellation to be used when creating rotation circles
  111549. * @param useEulerRotation Use and update Euler angle instead of quaternion
  111550. */
  111551. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  111552. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111553. /**
  111554. * If the gizmo is enabled
  111555. */
  111556. isEnabled: boolean;
  111557. /**
  111558. * Disposes of the gizmo
  111559. */
  111560. dispose(): void;
  111561. }
  111562. }
  111563. declare module BABYLON {
  111564. /**
  111565. * Gizmo that enables rotating a mesh along 3 axis
  111566. */
  111567. export class RotationGizmo extends Gizmo {
  111568. /**
  111569. * Internal gizmo used for interactions on the x axis
  111570. */
  111571. xGizmo: PlaneRotationGizmo;
  111572. /**
  111573. * Internal gizmo used for interactions on the y axis
  111574. */
  111575. yGizmo: PlaneRotationGizmo;
  111576. /**
  111577. * Internal gizmo used for interactions on the z axis
  111578. */
  111579. zGizmo: PlaneRotationGizmo;
  111580. /** Fires an event when any of it's sub gizmos are dragged */
  111581. onDragStartObservable: Observable<unknown>;
  111582. /** Fires an event when any of it's sub gizmos are released from dragging */
  111583. onDragEndObservable: Observable<unknown>;
  111584. private _meshAttached;
  111585. attachedMesh: Nullable<AbstractMesh>;
  111586. /**
  111587. * Creates a RotationGizmo
  111588. * @param gizmoLayer The utility layer the gizmo will be added to
  111589. * @param tessellation Amount of tessellation to be used when creating rotation circles
  111590. * @param useEulerRotation Use and update Euler angle instead of quaternion
  111591. */
  111592. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  111593. updateGizmoRotationToMatchAttachedMesh: boolean;
  111594. /**
  111595. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111596. */
  111597. snapDistance: number;
  111598. /**
  111599. * Ratio for the scale of the gizmo (Default: 1)
  111600. */
  111601. scaleRatio: number;
  111602. /**
  111603. * Disposes of the gizmo
  111604. */
  111605. dispose(): void;
  111606. /**
  111607. * CustomMeshes are not supported by this gizmo
  111608. * @param mesh The mesh to replace the default mesh of the gizmo
  111609. */
  111610. setCustomMesh(mesh: Mesh): void;
  111611. }
  111612. }
  111613. declare module BABYLON {
  111614. /**
  111615. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  111616. */
  111617. export class GizmoManager implements IDisposable {
  111618. private scene;
  111619. /**
  111620. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  111621. */
  111622. gizmos: {
  111623. positionGizmo: Nullable<PositionGizmo>;
  111624. rotationGizmo: Nullable<RotationGizmo>;
  111625. scaleGizmo: Nullable<ScaleGizmo>;
  111626. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  111627. };
  111628. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  111629. clearGizmoOnEmptyPointerEvent: boolean;
  111630. /** Fires an event when the manager is attached to a mesh */
  111631. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  111632. private _gizmosEnabled;
  111633. private _pointerObserver;
  111634. private _attachedMesh;
  111635. private _boundingBoxColor;
  111636. private _defaultUtilityLayer;
  111637. private _defaultKeepDepthUtilityLayer;
  111638. /**
  111639. * When bounding box gizmo is enabled, this can be used to track drag/end events
  111640. */
  111641. boundingBoxDragBehavior: SixDofDragBehavior;
  111642. /**
  111643. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  111644. */
  111645. attachableMeshes: Nullable<Array<AbstractMesh>>;
  111646. /**
  111647. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  111648. */
  111649. usePointerToAttachGizmos: boolean;
  111650. /**
  111651. * Utility layer that the bounding box gizmo belongs to
  111652. */
  111653. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  111654. /**
  111655. * Utility layer that all gizmos besides bounding box belong to
  111656. */
  111657. readonly utilityLayer: UtilityLayerRenderer;
  111658. /**
  111659. * Instatiates a gizmo manager
  111660. * @param scene the scene to overlay the gizmos on top of
  111661. */
  111662. constructor(scene: Scene);
  111663. /**
  111664. * Attaches a set of gizmos to the specified mesh
  111665. * @param mesh The mesh the gizmo's should be attached to
  111666. */
  111667. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  111668. /**
  111669. * If the position gizmo is enabled
  111670. */
  111671. positionGizmoEnabled: boolean;
  111672. /**
  111673. * If the rotation gizmo is enabled
  111674. */
  111675. rotationGizmoEnabled: boolean;
  111676. /**
  111677. * If the scale gizmo is enabled
  111678. */
  111679. scaleGizmoEnabled: boolean;
  111680. /**
  111681. * If the boundingBox gizmo is enabled
  111682. */
  111683. boundingBoxGizmoEnabled: boolean;
  111684. /**
  111685. * Disposes of the gizmo manager
  111686. */
  111687. dispose(): void;
  111688. }
  111689. }
  111690. declare module BABYLON {
  111691. /**
  111692. * A directional light is defined by a direction (what a surprise!).
  111693. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  111694. * 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.
  111695. * Documentation: https://doc.babylonjs.com/babylon101/lights
  111696. */
  111697. export class DirectionalLight extends ShadowLight {
  111698. private _shadowFrustumSize;
  111699. /**
  111700. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  111701. */
  111702. /**
  111703. * Specifies a fix frustum size for the shadow generation.
  111704. */
  111705. shadowFrustumSize: number;
  111706. private _shadowOrthoScale;
  111707. /**
  111708. * Gets the shadow projection scale against the optimal computed one.
  111709. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  111710. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  111711. */
  111712. /**
  111713. * Sets the shadow projection scale against the optimal computed one.
  111714. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  111715. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  111716. */
  111717. shadowOrthoScale: number;
  111718. /**
  111719. * Automatically compute the projection matrix to best fit (including all the casters)
  111720. * on each frame.
  111721. */
  111722. autoUpdateExtends: boolean;
  111723. private _orthoLeft;
  111724. private _orthoRight;
  111725. private _orthoTop;
  111726. private _orthoBottom;
  111727. /**
  111728. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  111729. * The directional light is emitted from everywhere in the given direction.
  111730. * It can cast shadows.
  111731. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111732. * @param name The friendly name of the light
  111733. * @param direction The direction of the light
  111734. * @param scene The scene the light belongs to
  111735. */
  111736. constructor(name: string, direction: Vector3, scene: Scene);
  111737. /**
  111738. * Returns the string "DirectionalLight".
  111739. * @return The class name
  111740. */
  111741. getClassName(): string;
  111742. /**
  111743. * Returns the integer 1.
  111744. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111745. */
  111746. getTypeID(): number;
  111747. /**
  111748. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  111749. * Returns the DirectionalLight Shadow projection matrix.
  111750. */
  111751. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111752. /**
  111753. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  111754. * Returns the DirectionalLight Shadow projection matrix.
  111755. */
  111756. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  111757. /**
  111758. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  111759. * Returns the DirectionalLight Shadow projection matrix.
  111760. */
  111761. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111762. protected _buildUniformLayout(): void;
  111763. /**
  111764. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  111765. * @param effect The effect to update
  111766. * @param lightIndex The index of the light in the effect to update
  111767. * @returns The directional light
  111768. */
  111769. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  111770. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  111771. /**
  111772. * Gets the minZ used for shadow according to both the scene and the light.
  111773. *
  111774. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  111775. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  111776. * @param activeCamera The camera we are returning the min for
  111777. * @returns the depth min z
  111778. */
  111779. getDepthMinZ(activeCamera: Camera): number;
  111780. /**
  111781. * Gets the maxZ used for shadow according to both the scene and the light.
  111782. *
  111783. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  111784. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  111785. * @param activeCamera The camera we are returning the max for
  111786. * @returns the depth max z
  111787. */
  111788. getDepthMaxZ(activeCamera: Camera): number;
  111789. /**
  111790. * Prepares the list of defines specific to the light type.
  111791. * @param defines the list of defines
  111792. * @param lightIndex defines the index of the light for the effect
  111793. */
  111794. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111795. }
  111796. }
  111797. declare module BABYLON {
  111798. /**
  111799. * Class containing static functions to help procedurally build meshes
  111800. */
  111801. export class HemisphereBuilder {
  111802. /**
  111803. * Creates a hemisphere mesh
  111804. * @param name defines the name of the mesh
  111805. * @param options defines the options used to create the mesh
  111806. * @param scene defines the hosting scene
  111807. * @returns the hemisphere mesh
  111808. */
  111809. static CreateHemisphere(name: string, options: {
  111810. segments?: number;
  111811. diameter?: number;
  111812. sideOrientation?: number;
  111813. }, scene: any): Mesh;
  111814. }
  111815. }
  111816. declare module BABYLON {
  111817. /**
  111818. * A spot light is defined by a position, a direction, an angle, and an exponent.
  111819. * These values define a cone of light starting from the position, emitting toward the direction.
  111820. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  111821. * and the exponent defines the speed of the decay of the light with distance (reach).
  111822. * Documentation: https://doc.babylonjs.com/babylon101/lights
  111823. */
  111824. export class SpotLight extends ShadowLight {
  111825. private _angle;
  111826. private _innerAngle;
  111827. private _cosHalfAngle;
  111828. private _lightAngleScale;
  111829. private _lightAngleOffset;
  111830. /**
  111831. * Gets the cone angle of the spot light in Radians.
  111832. */
  111833. /**
  111834. * Sets the cone angle of the spot light in Radians.
  111835. */
  111836. angle: number;
  111837. /**
  111838. * Only used in gltf falloff mode, this defines the angle where
  111839. * the directional falloff will start before cutting at angle which could be seen
  111840. * as outer angle.
  111841. */
  111842. /**
  111843. * Only used in gltf falloff mode, this defines the angle where
  111844. * the directional falloff will start before cutting at angle which could be seen
  111845. * as outer angle.
  111846. */
  111847. innerAngle: number;
  111848. private _shadowAngleScale;
  111849. /**
  111850. * Allows scaling the angle of the light for shadow generation only.
  111851. */
  111852. /**
  111853. * Allows scaling the angle of the light for shadow generation only.
  111854. */
  111855. shadowAngleScale: number;
  111856. /**
  111857. * The light decay speed with the distance from the emission spot.
  111858. */
  111859. exponent: number;
  111860. private _projectionTextureMatrix;
  111861. /**
  111862. * Allows reading the projecton texture
  111863. */
  111864. readonly projectionTextureMatrix: Matrix;
  111865. protected _projectionTextureLightNear: number;
  111866. /**
  111867. * Gets the near clip of the Spotlight for texture projection.
  111868. */
  111869. /**
  111870. * Sets the near clip of the Spotlight for texture projection.
  111871. */
  111872. projectionTextureLightNear: number;
  111873. protected _projectionTextureLightFar: number;
  111874. /**
  111875. * Gets the far clip of the Spotlight for texture projection.
  111876. */
  111877. /**
  111878. * Sets the far clip of the Spotlight for texture projection.
  111879. */
  111880. projectionTextureLightFar: number;
  111881. protected _projectionTextureUpDirection: Vector3;
  111882. /**
  111883. * Gets the Up vector of the Spotlight for texture projection.
  111884. */
  111885. /**
  111886. * Sets the Up vector of the Spotlight for texture projection.
  111887. */
  111888. projectionTextureUpDirection: Vector3;
  111889. private _projectionTexture;
  111890. /**
  111891. * Gets the projection texture of the light.
  111892. */
  111893. /**
  111894. * Sets the projection texture of the light.
  111895. */
  111896. projectionTexture: Nullable<BaseTexture>;
  111897. private _projectionTextureViewLightDirty;
  111898. private _projectionTextureProjectionLightDirty;
  111899. private _projectionTextureDirty;
  111900. private _projectionTextureViewTargetVector;
  111901. private _projectionTextureViewLightMatrix;
  111902. private _projectionTextureProjectionLightMatrix;
  111903. private _projectionTextureScalingMatrix;
  111904. /**
  111905. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  111906. * It can cast shadows.
  111907. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111908. * @param name The light friendly name
  111909. * @param position The position of the spot light in the scene
  111910. * @param direction The direction of the light in the scene
  111911. * @param angle The cone angle of the light in Radians
  111912. * @param exponent The light decay speed with the distance from the emission spot
  111913. * @param scene The scene the lights belongs to
  111914. */
  111915. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  111916. /**
  111917. * Returns the string "SpotLight".
  111918. * @returns the class name
  111919. */
  111920. getClassName(): string;
  111921. /**
  111922. * Returns the integer 2.
  111923. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111924. */
  111925. getTypeID(): number;
  111926. /**
  111927. * Overrides the direction setter to recompute the projection texture view light Matrix.
  111928. */
  111929. protected _setDirection(value: Vector3): void;
  111930. /**
  111931. * Overrides the position setter to recompute the projection texture view light Matrix.
  111932. */
  111933. protected _setPosition(value: Vector3): void;
  111934. /**
  111935. * 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.
  111936. * Returns the SpotLight.
  111937. */
  111938. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111939. protected _computeProjectionTextureViewLightMatrix(): void;
  111940. protected _computeProjectionTextureProjectionLightMatrix(): void;
  111941. /**
  111942. * Main function for light texture projection matrix computing.
  111943. */
  111944. protected _computeProjectionTextureMatrix(): void;
  111945. protected _buildUniformLayout(): void;
  111946. private _computeAngleValues;
  111947. /**
  111948. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  111949. * @param effect The effect to update
  111950. * @param lightIndex The index of the light in the effect to update
  111951. * @returns The spot light
  111952. */
  111953. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  111954. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  111955. /**
  111956. * Disposes the light and the associated resources.
  111957. */
  111958. dispose(): void;
  111959. /**
  111960. * Prepares the list of defines specific to the light type.
  111961. * @param defines the list of defines
  111962. * @param lightIndex defines the index of the light for the effect
  111963. */
  111964. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111965. }
  111966. }
  111967. declare module BABYLON {
  111968. /**
  111969. * Gizmo that enables viewing a light
  111970. */
  111971. export class LightGizmo extends Gizmo {
  111972. private _lightMesh;
  111973. private _material;
  111974. private cachedPosition;
  111975. private cachedForward;
  111976. /**
  111977. * Creates a LightGizmo
  111978. * @param gizmoLayer The utility layer the gizmo will be added to
  111979. */
  111980. constructor(gizmoLayer?: UtilityLayerRenderer);
  111981. private _light;
  111982. /**
  111983. * The light that the gizmo is attached to
  111984. */
  111985. light: Nullable<Light>;
  111986. /**
  111987. * Gets the material used to render the light gizmo
  111988. */
  111989. readonly material: StandardMaterial;
  111990. /**
  111991. * @hidden
  111992. * Updates the gizmo to match the attached mesh's position/rotation
  111993. */
  111994. protected _update(): void;
  111995. private static _Scale;
  111996. /**
  111997. * Creates the lines for a light mesh
  111998. */
  111999. private static _createLightLines;
  112000. /**
  112001. * Disposes of the light gizmo
  112002. */
  112003. dispose(): void;
  112004. private static _CreateHemisphericLightMesh;
  112005. private static _CreatePointLightMesh;
  112006. private static _CreateSpotLightMesh;
  112007. private static _CreateDirectionalLightMesh;
  112008. }
  112009. }
  112010. declare module BABYLON {
  112011. /** @hidden */
  112012. export var backgroundFragmentDeclaration: {
  112013. name: string;
  112014. shader: string;
  112015. };
  112016. }
  112017. declare module BABYLON {
  112018. /** @hidden */
  112019. export var backgroundUboDeclaration: {
  112020. name: string;
  112021. shader: string;
  112022. };
  112023. }
  112024. declare module BABYLON {
  112025. /** @hidden */
  112026. export var backgroundPixelShader: {
  112027. name: string;
  112028. shader: string;
  112029. };
  112030. }
  112031. declare module BABYLON {
  112032. /** @hidden */
  112033. export var backgroundVertexDeclaration: {
  112034. name: string;
  112035. shader: string;
  112036. };
  112037. }
  112038. declare module BABYLON {
  112039. /** @hidden */
  112040. export var backgroundVertexShader: {
  112041. name: string;
  112042. shader: string;
  112043. };
  112044. }
  112045. declare module BABYLON {
  112046. /**
  112047. * Background material used to create an efficient environement around your scene.
  112048. */
  112049. export class BackgroundMaterial extends PushMaterial {
  112050. /**
  112051. * Standard reflectance value at parallel view angle.
  112052. */
  112053. static StandardReflectance0: number;
  112054. /**
  112055. * Standard reflectance value at grazing angle.
  112056. */
  112057. static StandardReflectance90: number;
  112058. protected _primaryColor: Color3;
  112059. /**
  112060. * Key light Color (multiply against the environement texture)
  112061. */
  112062. primaryColor: Color3;
  112063. protected __perceptualColor: Nullable<Color3>;
  112064. /**
  112065. * Experimental Internal Use Only.
  112066. *
  112067. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  112068. * This acts as a helper to set the primary color to a more "human friendly" value.
  112069. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  112070. * output color as close as possible from the chosen value.
  112071. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  112072. * part of lighting setup.)
  112073. */
  112074. _perceptualColor: Nullable<Color3>;
  112075. protected _primaryColorShadowLevel: float;
  112076. /**
  112077. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  112078. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  112079. */
  112080. primaryColorShadowLevel: float;
  112081. protected _primaryColorHighlightLevel: float;
  112082. /**
  112083. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  112084. * The primary color is used at the level chosen to define what the white area would look.
  112085. */
  112086. primaryColorHighlightLevel: float;
  112087. protected _reflectionTexture: Nullable<BaseTexture>;
  112088. /**
  112089. * Reflection Texture used in the material.
  112090. * Should be author in a specific way for the best result (refer to the documentation).
  112091. */
  112092. reflectionTexture: Nullable<BaseTexture>;
  112093. protected _reflectionBlur: float;
  112094. /**
  112095. * Reflection Texture level of blur.
  112096. *
  112097. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  112098. * texture twice.
  112099. */
  112100. reflectionBlur: float;
  112101. protected _diffuseTexture: Nullable<BaseTexture>;
  112102. /**
  112103. * Diffuse Texture used in the material.
  112104. * Should be author in a specific way for the best result (refer to the documentation).
  112105. */
  112106. diffuseTexture: Nullable<BaseTexture>;
  112107. protected _shadowLights: Nullable<IShadowLight[]>;
  112108. /**
  112109. * Specify the list of lights casting shadow on the material.
  112110. * All scene shadow lights will be included if null.
  112111. */
  112112. shadowLights: Nullable<IShadowLight[]>;
  112113. protected _shadowLevel: float;
  112114. /**
  112115. * Helps adjusting the shadow to a softer level if required.
  112116. * 0 means black shadows and 1 means no shadows.
  112117. */
  112118. shadowLevel: float;
  112119. protected _sceneCenter: Vector3;
  112120. /**
  112121. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  112122. * It is usually zero but might be interesting to modify according to your setup.
  112123. */
  112124. sceneCenter: Vector3;
  112125. protected _opacityFresnel: boolean;
  112126. /**
  112127. * This helps specifying that the material is falling off to the sky box at grazing angle.
  112128. * This helps ensuring a nice transition when the camera goes under the ground.
  112129. */
  112130. opacityFresnel: boolean;
  112131. protected _reflectionFresnel: boolean;
  112132. /**
  112133. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  112134. * This helps adding a mirror texture on the ground.
  112135. */
  112136. reflectionFresnel: boolean;
  112137. protected _reflectionFalloffDistance: number;
  112138. /**
  112139. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  112140. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  112141. */
  112142. reflectionFalloffDistance: number;
  112143. protected _reflectionAmount: number;
  112144. /**
  112145. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  112146. */
  112147. reflectionAmount: number;
  112148. protected _reflectionReflectance0: number;
  112149. /**
  112150. * This specifies the weight of the reflection at grazing angle.
  112151. */
  112152. reflectionReflectance0: number;
  112153. protected _reflectionReflectance90: number;
  112154. /**
  112155. * This specifies the weight of the reflection at a perpendicular point of view.
  112156. */
  112157. reflectionReflectance90: number;
  112158. /**
  112159. * Sets the reflection reflectance fresnel values according to the default standard
  112160. * empirically know to work well :-)
  112161. */
  112162. reflectionStandardFresnelWeight: number;
  112163. protected _useRGBColor: boolean;
  112164. /**
  112165. * Helps to directly use the maps channels instead of their level.
  112166. */
  112167. useRGBColor: boolean;
  112168. protected _enableNoise: boolean;
  112169. /**
  112170. * This helps reducing the banding effect that could occur on the background.
  112171. */
  112172. enableNoise: boolean;
  112173. /**
  112174. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112175. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  112176. * Recommended to be keep at 1.0 except for special cases.
  112177. */
  112178. fovMultiplier: number;
  112179. private _fovMultiplier;
  112180. /**
  112181. * Enable the FOV adjustment feature controlled by fovMultiplier.
  112182. */
  112183. useEquirectangularFOV: boolean;
  112184. private _maxSimultaneousLights;
  112185. /**
  112186. * Number of Simultaneous lights allowed on the material.
  112187. */
  112188. maxSimultaneousLights: int;
  112189. /**
  112190. * Default configuration related to image processing available in the Background Material.
  112191. */
  112192. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112193. /**
  112194. * Keep track of the image processing observer to allow dispose and replace.
  112195. */
  112196. private _imageProcessingObserver;
  112197. /**
  112198. * Attaches a new image processing configuration to the PBR Material.
  112199. * @param configuration (if null the scene configuration will be use)
  112200. */
  112201. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  112202. /**
  112203. * Gets the image processing configuration used either in this material.
  112204. */
  112205. /**
  112206. * Sets the Default image processing configuration used either in the this material.
  112207. *
  112208. * If sets to null, the scene one is in use.
  112209. */
  112210. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  112211. /**
  112212. * Gets wether the color curves effect is enabled.
  112213. */
  112214. /**
  112215. * Sets wether the color curves effect is enabled.
  112216. */
  112217. cameraColorCurvesEnabled: boolean;
  112218. /**
  112219. * Gets wether the color grading effect is enabled.
  112220. */
  112221. /**
  112222. * Gets wether the color grading effect is enabled.
  112223. */
  112224. cameraColorGradingEnabled: boolean;
  112225. /**
  112226. * Gets wether tonemapping is enabled or not.
  112227. */
  112228. /**
  112229. * Sets wether tonemapping is enabled or not
  112230. */
  112231. cameraToneMappingEnabled: boolean;
  112232. /**
  112233. * The camera exposure used on this material.
  112234. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112235. * This corresponds to a photographic exposure.
  112236. */
  112237. /**
  112238. * The camera exposure used on this material.
  112239. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112240. * This corresponds to a photographic exposure.
  112241. */
  112242. cameraExposure: float;
  112243. /**
  112244. * Gets The camera contrast used on this material.
  112245. */
  112246. /**
  112247. * Sets The camera contrast used on this material.
  112248. */
  112249. cameraContrast: float;
  112250. /**
  112251. * Gets the Color Grading 2D Lookup Texture.
  112252. */
  112253. /**
  112254. * Sets the Color Grading 2D Lookup Texture.
  112255. */
  112256. cameraColorGradingTexture: Nullable<BaseTexture>;
  112257. /**
  112258. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112259. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112260. * 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;
  112261. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112262. */
  112263. /**
  112264. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112265. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112266. * 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;
  112267. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112268. */
  112269. cameraColorCurves: Nullable<ColorCurves>;
  112270. /**
  112271. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  112272. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  112273. */
  112274. switchToBGR: boolean;
  112275. private _renderTargets;
  112276. private _reflectionControls;
  112277. private _white;
  112278. private _primaryShadowColor;
  112279. private _primaryHighlightColor;
  112280. /**
  112281. * Instantiates a Background Material in the given scene
  112282. * @param name The friendly name of the material
  112283. * @param scene The scene to add the material to
  112284. */
  112285. constructor(name: string, scene: Scene);
  112286. /**
  112287. * Gets a boolean indicating that current material needs to register RTT
  112288. */
  112289. readonly hasRenderTargetTextures: boolean;
  112290. /**
  112291. * The entire material has been created in order to prevent overdraw.
  112292. * @returns false
  112293. */
  112294. needAlphaTesting(): boolean;
  112295. /**
  112296. * The entire material has been created in order to prevent overdraw.
  112297. * @returns true if blending is enable
  112298. */
  112299. needAlphaBlending(): boolean;
  112300. /**
  112301. * Checks wether the material is ready to be rendered for a given mesh.
  112302. * @param mesh The mesh to render
  112303. * @param subMesh The submesh to check against
  112304. * @param useInstances Specify wether or not the material is used with instances
  112305. * @returns true if all the dependencies are ready (Textures, Effects...)
  112306. */
  112307. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  112308. /**
  112309. * Compute the primary color according to the chosen perceptual color.
  112310. */
  112311. private _computePrimaryColorFromPerceptualColor;
  112312. /**
  112313. * Compute the highlights and shadow colors according to their chosen levels.
  112314. */
  112315. private _computePrimaryColors;
  112316. /**
  112317. * Build the uniform buffer used in the material.
  112318. */
  112319. buildUniformLayout(): void;
  112320. /**
  112321. * Unbind the material.
  112322. */
  112323. unbind(): void;
  112324. /**
  112325. * Bind only the world matrix to the material.
  112326. * @param world The world matrix to bind.
  112327. */
  112328. bindOnlyWorldMatrix(world: Matrix): void;
  112329. /**
  112330. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  112331. * @param world The world matrix to bind.
  112332. * @param subMesh The submesh to bind for.
  112333. */
  112334. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  112335. /**
  112336. * Checks to see if a texture is used in the material.
  112337. * @param texture - Base texture to use.
  112338. * @returns - Boolean specifying if a texture is used in the material.
  112339. */
  112340. hasTexture(texture: BaseTexture): boolean;
  112341. /**
  112342. * Dispose the material.
  112343. * @param forceDisposeEffect Force disposal of the associated effect.
  112344. * @param forceDisposeTextures Force disposal of the associated textures.
  112345. */
  112346. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  112347. /**
  112348. * Clones the material.
  112349. * @param name The cloned name.
  112350. * @returns The cloned material.
  112351. */
  112352. clone(name: string): BackgroundMaterial;
  112353. /**
  112354. * Serializes the current material to its JSON representation.
  112355. * @returns The JSON representation.
  112356. */
  112357. serialize(): any;
  112358. /**
  112359. * Gets the class name of the material
  112360. * @returns "BackgroundMaterial"
  112361. */
  112362. getClassName(): string;
  112363. /**
  112364. * Parse a JSON input to create back a background material.
  112365. * @param source The JSON data to parse
  112366. * @param scene The scene to create the parsed material in
  112367. * @param rootUrl The root url of the assets the material depends upon
  112368. * @returns the instantiated BackgroundMaterial.
  112369. */
  112370. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  112371. }
  112372. }
  112373. declare module BABYLON {
  112374. /**
  112375. * Represents the different options available during the creation of
  112376. * a Environment helper.
  112377. *
  112378. * This can control the default ground, skybox and image processing setup of your scene.
  112379. */
  112380. export interface IEnvironmentHelperOptions {
  112381. /**
  112382. * Specifies wether or not to create a ground.
  112383. * True by default.
  112384. */
  112385. createGround: boolean;
  112386. /**
  112387. * Specifies the ground size.
  112388. * 15 by default.
  112389. */
  112390. groundSize: number;
  112391. /**
  112392. * The texture used on the ground for the main color.
  112393. * Comes from the BabylonJS CDN by default.
  112394. *
  112395. * Remarks: Can be either a texture or a url.
  112396. */
  112397. groundTexture: string | BaseTexture;
  112398. /**
  112399. * The color mixed in the ground texture by default.
  112400. * BabylonJS clearColor by default.
  112401. */
  112402. groundColor: Color3;
  112403. /**
  112404. * Specifies the ground opacity.
  112405. * 1 by default.
  112406. */
  112407. groundOpacity: number;
  112408. /**
  112409. * Enables the ground to receive shadows.
  112410. * True by default.
  112411. */
  112412. enableGroundShadow: boolean;
  112413. /**
  112414. * Helps preventing the shadow to be fully black on the ground.
  112415. * 0.5 by default.
  112416. */
  112417. groundShadowLevel: number;
  112418. /**
  112419. * Creates a mirror texture attach to the ground.
  112420. * false by default.
  112421. */
  112422. enableGroundMirror: boolean;
  112423. /**
  112424. * Specifies the ground mirror size ratio.
  112425. * 0.3 by default as the default kernel is 64.
  112426. */
  112427. groundMirrorSizeRatio: number;
  112428. /**
  112429. * Specifies the ground mirror blur kernel size.
  112430. * 64 by default.
  112431. */
  112432. groundMirrorBlurKernel: number;
  112433. /**
  112434. * Specifies the ground mirror visibility amount.
  112435. * 1 by default
  112436. */
  112437. groundMirrorAmount: number;
  112438. /**
  112439. * Specifies the ground mirror reflectance weight.
  112440. * This uses the standard weight of the background material to setup the fresnel effect
  112441. * of the mirror.
  112442. * 1 by default.
  112443. */
  112444. groundMirrorFresnelWeight: number;
  112445. /**
  112446. * Specifies the ground mirror Falloff distance.
  112447. * This can helps reducing the size of the reflection.
  112448. * 0 by Default.
  112449. */
  112450. groundMirrorFallOffDistance: number;
  112451. /**
  112452. * Specifies the ground mirror texture type.
  112453. * Unsigned Int by Default.
  112454. */
  112455. groundMirrorTextureType: number;
  112456. /**
  112457. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  112458. * the shown objects.
  112459. */
  112460. groundYBias: number;
  112461. /**
  112462. * Specifies wether or not to create a skybox.
  112463. * True by default.
  112464. */
  112465. createSkybox: boolean;
  112466. /**
  112467. * Specifies the skybox size.
  112468. * 20 by default.
  112469. */
  112470. skyboxSize: number;
  112471. /**
  112472. * The texture used on the skybox for the main color.
  112473. * Comes from the BabylonJS CDN by default.
  112474. *
  112475. * Remarks: Can be either a texture or a url.
  112476. */
  112477. skyboxTexture: string | BaseTexture;
  112478. /**
  112479. * The color mixed in the skybox texture by default.
  112480. * BabylonJS clearColor by default.
  112481. */
  112482. skyboxColor: Color3;
  112483. /**
  112484. * The background rotation around the Y axis of the scene.
  112485. * This helps aligning the key lights of your scene with the background.
  112486. * 0 by default.
  112487. */
  112488. backgroundYRotation: number;
  112489. /**
  112490. * Compute automatically the size of the elements to best fit with the scene.
  112491. */
  112492. sizeAuto: boolean;
  112493. /**
  112494. * Default position of the rootMesh if autoSize is not true.
  112495. */
  112496. rootPosition: Vector3;
  112497. /**
  112498. * Sets up the image processing in the scene.
  112499. * true by default.
  112500. */
  112501. setupImageProcessing: boolean;
  112502. /**
  112503. * The texture used as your environment texture in the scene.
  112504. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  112505. *
  112506. * Remarks: Can be either a texture or a url.
  112507. */
  112508. environmentTexture: string | BaseTexture;
  112509. /**
  112510. * The value of the exposure to apply to the scene.
  112511. * 0.6 by default if setupImageProcessing is true.
  112512. */
  112513. cameraExposure: number;
  112514. /**
  112515. * The value of the contrast to apply to the scene.
  112516. * 1.6 by default if setupImageProcessing is true.
  112517. */
  112518. cameraContrast: number;
  112519. /**
  112520. * Specifies wether or not tonemapping should be enabled in the scene.
  112521. * true by default if setupImageProcessing is true.
  112522. */
  112523. toneMappingEnabled: boolean;
  112524. }
  112525. /**
  112526. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  112527. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  112528. * It also helps with the default setup of your imageProcessing configuration.
  112529. */
  112530. export class EnvironmentHelper {
  112531. /**
  112532. * Default ground texture URL.
  112533. */
  112534. private static _groundTextureCDNUrl;
  112535. /**
  112536. * Default skybox texture URL.
  112537. */
  112538. private static _skyboxTextureCDNUrl;
  112539. /**
  112540. * Default environment texture URL.
  112541. */
  112542. private static _environmentTextureCDNUrl;
  112543. /**
  112544. * Creates the default options for the helper.
  112545. */
  112546. private static _getDefaultOptions;
  112547. private _rootMesh;
  112548. /**
  112549. * Gets the root mesh created by the helper.
  112550. */
  112551. readonly rootMesh: Mesh;
  112552. private _skybox;
  112553. /**
  112554. * Gets the skybox created by the helper.
  112555. */
  112556. readonly skybox: Nullable<Mesh>;
  112557. private _skyboxTexture;
  112558. /**
  112559. * Gets the skybox texture created by the helper.
  112560. */
  112561. readonly skyboxTexture: Nullable<BaseTexture>;
  112562. private _skyboxMaterial;
  112563. /**
  112564. * Gets the skybox material created by the helper.
  112565. */
  112566. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  112567. private _ground;
  112568. /**
  112569. * Gets the ground mesh created by the helper.
  112570. */
  112571. readonly ground: Nullable<Mesh>;
  112572. private _groundTexture;
  112573. /**
  112574. * Gets the ground texture created by the helper.
  112575. */
  112576. readonly groundTexture: Nullable<BaseTexture>;
  112577. private _groundMirror;
  112578. /**
  112579. * Gets the ground mirror created by the helper.
  112580. */
  112581. readonly groundMirror: Nullable<MirrorTexture>;
  112582. /**
  112583. * Gets the ground mirror render list to helps pushing the meshes
  112584. * you wish in the ground reflection.
  112585. */
  112586. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  112587. private _groundMaterial;
  112588. /**
  112589. * Gets the ground material created by the helper.
  112590. */
  112591. readonly groundMaterial: Nullable<BackgroundMaterial>;
  112592. /**
  112593. * Stores the creation options.
  112594. */
  112595. private readonly _scene;
  112596. private _options;
  112597. /**
  112598. * This observable will be notified with any error during the creation of the environment,
  112599. * mainly texture creation errors.
  112600. */
  112601. onErrorObservable: Observable<{
  112602. message?: string;
  112603. exception?: any;
  112604. }>;
  112605. /**
  112606. * constructor
  112607. * @param options Defines the options we want to customize the helper
  112608. * @param scene The scene to add the material to
  112609. */
  112610. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  112611. /**
  112612. * Updates the background according to the new options
  112613. * @param options
  112614. */
  112615. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  112616. /**
  112617. * Sets the primary color of all the available elements.
  112618. * @param color the main color to affect to the ground and the background
  112619. */
  112620. setMainColor(color: Color3): void;
  112621. /**
  112622. * Setup the image processing according to the specified options.
  112623. */
  112624. private _setupImageProcessing;
  112625. /**
  112626. * Setup the environment texture according to the specified options.
  112627. */
  112628. private _setupEnvironmentTexture;
  112629. /**
  112630. * Setup the background according to the specified options.
  112631. */
  112632. private _setupBackground;
  112633. /**
  112634. * Get the scene sizes according to the setup.
  112635. */
  112636. private _getSceneSize;
  112637. /**
  112638. * Setup the ground according to the specified options.
  112639. */
  112640. private _setupGround;
  112641. /**
  112642. * Setup the ground material according to the specified options.
  112643. */
  112644. private _setupGroundMaterial;
  112645. /**
  112646. * Setup the ground diffuse texture according to the specified options.
  112647. */
  112648. private _setupGroundDiffuseTexture;
  112649. /**
  112650. * Setup the ground mirror texture according to the specified options.
  112651. */
  112652. private _setupGroundMirrorTexture;
  112653. /**
  112654. * Setup the ground to receive the mirror texture.
  112655. */
  112656. private _setupMirrorInGroundMaterial;
  112657. /**
  112658. * Setup the skybox according to the specified options.
  112659. */
  112660. private _setupSkybox;
  112661. /**
  112662. * Setup the skybox material according to the specified options.
  112663. */
  112664. private _setupSkyboxMaterial;
  112665. /**
  112666. * Setup the skybox reflection texture according to the specified options.
  112667. */
  112668. private _setupSkyboxReflectionTexture;
  112669. private _errorHandler;
  112670. /**
  112671. * Dispose all the elements created by the Helper.
  112672. */
  112673. dispose(): void;
  112674. }
  112675. }
  112676. declare module BABYLON {
  112677. /**
  112678. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  112679. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  112680. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  112681. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  112682. */
  112683. export class PhotoDome extends TransformNode {
  112684. /**
  112685. * Define the image as a Monoscopic panoramic 360 image.
  112686. */
  112687. static readonly MODE_MONOSCOPIC: number;
  112688. /**
  112689. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  112690. */
  112691. static readonly MODE_TOPBOTTOM: number;
  112692. /**
  112693. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  112694. */
  112695. static readonly MODE_SIDEBYSIDE: number;
  112696. private _useDirectMapping;
  112697. /**
  112698. * The texture being displayed on the sphere
  112699. */
  112700. protected _photoTexture: Texture;
  112701. /**
  112702. * Gets or sets the texture being displayed on the sphere
  112703. */
  112704. photoTexture: Texture;
  112705. /**
  112706. * Observable raised when an error occured while loading the 360 image
  112707. */
  112708. onLoadErrorObservable: Observable<string>;
  112709. /**
  112710. * The skybox material
  112711. */
  112712. protected _material: BackgroundMaterial;
  112713. /**
  112714. * The surface used for the skybox
  112715. */
  112716. protected _mesh: Mesh;
  112717. /**
  112718. * Gets the mesh used for the skybox.
  112719. */
  112720. readonly mesh: Mesh;
  112721. /**
  112722. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112723. * Also see the options.resolution property.
  112724. */
  112725. fovMultiplier: number;
  112726. private _imageMode;
  112727. /**
  112728. * Gets or set the current video mode for the video. It can be:
  112729. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  112730. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  112731. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  112732. */
  112733. imageMode: number;
  112734. /**
  112735. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  112736. * @param name Element's name, child elements will append suffixes for their own names.
  112737. * @param urlsOfPhoto defines the url of the photo to display
  112738. * @param options defines an object containing optional or exposed sub element properties
  112739. * @param onError defines a callback called when an error occured while loading the texture
  112740. */
  112741. constructor(name: string, urlOfPhoto: string, options: {
  112742. resolution?: number;
  112743. size?: number;
  112744. useDirectMapping?: boolean;
  112745. faceForward?: boolean;
  112746. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  112747. private _onBeforeCameraRenderObserver;
  112748. private _changeImageMode;
  112749. /**
  112750. * Releases resources associated with this node.
  112751. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112752. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112753. */
  112754. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112755. }
  112756. }
  112757. declare module BABYLON {
  112758. /**
  112759. * Class used to host RGBD texture specific utilities
  112760. */
  112761. export class RGBDTextureTools {
  112762. /**
  112763. * Expand the RGBD Texture from RGBD to Half Float if possible.
  112764. * @param texture the texture to expand.
  112765. */
  112766. static ExpandRGBDTexture(texture: Texture): void;
  112767. }
  112768. }
  112769. declare module BABYLON {
  112770. /**
  112771. * Class used to host texture specific utilities
  112772. */
  112773. export class BRDFTextureTools {
  112774. /**
  112775. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  112776. * @param scene defines the hosting scene
  112777. * @returns the environment BRDF texture
  112778. */
  112779. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  112780. private static _environmentBRDFBase64Texture;
  112781. }
  112782. }
  112783. declare module BABYLON {
  112784. /**
  112785. * @hidden
  112786. */
  112787. export interface IMaterialClearCoatDefines {
  112788. CLEARCOAT: boolean;
  112789. CLEARCOAT_DEFAULTIOR: boolean;
  112790. CLEARCOAT_TEXTURE: boolean;
  112791. CLEARCOAT_TEXTUREDIRECTUV: number;
  112792. CLEARCOAT_BUMP: boolean;
  112793. CLEARCOAT_BUMPDIRECTUV: number;
  112794. CLEARCOAT_TINT: boolean;
  112795. CLEARCOAT_TINT_TEXTURE: boolean;
  112796. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  112797. /** @hidden */
  112798. _areTexturesDirty: boolean;
  112799. }
  112800. /**
  112801. * Define the code related to the clear coat parameters of the pbr material.
  112802. */
  112803. export class PBRClearCoatConfiguration {
  112804. /**
  112805. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  112806. * The default fits with a polyurethane material.
  112807. */
  112808. private static readonly _DefaultIndexOfRefraction;
  112809. private _isEnabled;
  112810. /**
  112811. * Defines if the clear coat is enabled in the material.
  112812. */
  112813. isEnabled: boolean;
  112814. /**
  112815. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  112816. */
  112817. intensity: number;
  112818. /**
  112819. * Defines the clear coat layer roughness.
  112820. */
  112821. roughness: number;
  112822. private _indexOfRefraction;
  112823. /**
  112824. * Defines the index of refraction of the clear coat.
  112825. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  112826. * The default fits with a polyurethane material.
  112827. * Changing the default value is more performance intensive.
  112828. */
  112829. indexOfRefraction: number;
  112830. private _texture;
  112831. /**
  112832. * Stores the clear coat values in a texture.
  112833. */
  112834. texture: Nullable<BaseTexture>;
  112835. private _bumpTexture;
  112836. /**
  112837. * Define the clear coat specific bump texture.
  112838. */
  112839. bumpTexture: Nullable<BaseTexture>;
  112840. private _isTintEnabled;
  112841. /**
  112842. * Defines if the clear coat tint is enabled in the material.
  112843. */
  112844. isTintEnabled: boolean;
  112845. /**
  112846. * Defines the clear coat tint of the material.
  112847. * This is only use if tint is enabled
  112848. */
  112849. tintColor: Color3;
  112850. /**
  112851. * Defines the distance at which the tint color should be found in the
  112852. * clear coat media.
  112853. * This is only use if tint is enabled
  112854. */
  112855. tintColorAtDistance: number;
  112856. /**
  112857. * Defines the clear coat layer thickness.
  112858. * This is only use if tint is enabled
  112859. */
  112860. tintThickness: number;
  112861. private _tintTexture;
  112862. /**
  112863. * Stores the clear tint values in a texture.
  112864. * rgb is tint
  112865. * a is a thickness factor
  112866. */
  112867. tintTexture: Nullable<BaseTexture>;
  112868. /** @hidden */
  112869. private _internalMarkAllSubMeshesAsTexturesDirty;
  112870. /** @hidden */
  112871. _markAllSubMeshesAsTexturesDirty(): void;
  112872. /**
  112873. * Instantiate a new istance of clear coat configuration.
  112874. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112875. */
  112876. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112877. /**
  112878. * Gets wehter the submesh is ready to be used or not.
  112879. * @param defines the list of "defines" to update.
  112880. * @param scene defines the scene the material belongs to.
  112881. * @param engine defines the engine the material belongs to.
  112882. * @param disableBumpMap defines wether the material disables bump or not.
  112883. * @returns - boolean indicating that the submesh is ready or not.
  112884. */
  112885. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  112886. /**
  112887. * Checks to see if a texture is used in the material.
  112888. * @param defines the list of "defines" to update.
  112889. * @param scene defines the scene to the material belongs to.
  112890. */
  112891. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  112892. /**
  112893. * Binds the material data.
  112894. * @param uniformBuffer defines the Uniform buffer to fill in.
  112895. * @param scene defines the scene the material belongs to.
  112896. * @param engine defines the engine the material belongs to.
  112897. * @param disableBumpMap defines wether the material disables bump or not.
  112898. * @param isFrozen defines wether the material is frozen or not.
  112899. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  112900. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  112901. */
  112902. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  112903. /**
  112904. * Checks to see if a texture is used in the material.
  112905. * @param texture - Base texture to use.
  112906. * @returns - Boolean specifying if a texture is used in the material.
  112907. */
  112908. hasTexture(texture: BaseTexture): boolean;
  112909. /**
  112910. * Returns an array of the actively used textures.
  112911. * @param activeTextures Array of BaseTextures
  112912. */
  112913. getActiveTextures(activeTextures: BaseTexture[]): void;
  112914. /**
  112915. * Returns the animatable textures.
  112916. * @param animatables Array of animatable textures.
  112917. */
  112918. getAnimatables(animatables: IAnimatable[]): void;
  112919. /**
  112920. * Disposes the resources of the material.
  112921. * @param forceDisposeTextures - Forces the disposal of all textures.
  112922. */
  112923. dispose(forceDisposeTextures?: boolean): void;
  112924. /**
  112925. * Get the current class name of the texture useful for serialization or dynamic coding.
  112926. * @returns "PBRClearCoatConfiguration"
  112927. */
  112928. getClassName(): string;
  112929. /**
  112930. * Add fallbacks to the effect fallbacks list.
  112931. * @param defines defines the Base texture to use.
  112932. * @param fallbacks defines the current fallback list.
  112933. * @param currentRank defines the current fallback rank.
  112934. * @returns the new fallback rank.
  112935. */
  112936. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112937. /**
  112938. * Add the required uniforms to the current list.
  112939. * @param uniforms defines the current uniform list.
  112940. */
  112941. static AddUniforms(uniforms: string[]): void;
  112942. /**
  112943. * Add the required samplers to the current list.
  112944. * @param samplers defines the current sampler list.
  112945. */
  112946. static AddSamplers(samplers: string[]): void;
  112947. /**
  112948. * Add the required uniforms to the current buffer.
  112949. * @param uniformBuffer defines the current uniform buffer.
  112950. */
  112951. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112952. /**
  112953. * Makes a duplicate of the current configuration into another one.
  112954. * @param clearCoatConfiguration define the config where to copy the info
  112955. */
  112956. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  112957. /**
  112958. * Serializes this clear coat configuration.
  112959. * @returns - An object with the serialized config.
  112960. */
  112961. serialize(): any;
  112962. /**
  112963. * Parses a anisotropy Configuration from a serialized object.
  112964. * @param source - Serialized object.
  112965. * @param scene Defines the scene we are parsing for
  112966. * @param rootUrl Defines the rootUrl to load from
  112967. */
  112968. parse(source: any, scene: Scene, rootUrl: string): void;
  112969. }
  112970. }
  112971. declare module BABYLON {
  112972. /**
  112973. * @hidden
  112974. */
  112975. export interface IMaterialAnisotropicDefines {
  112976. ANISOTROPIC: boolean;
  112977. ANISOTROPIC_TEXTURE: boolean;
  112978. ANISOTROPIC_TEXTUREDIRECTUV: number;
  112979. MAINUV1: boolean;
  112980. _areTexturesDirty: boolean;
  112981. _needUVs: boolean;
  112982. }
  112983. /**
  112984. * Define the code related to the anisotropic parameters of the pbr material.
  112985. */
  112986. export class PBRAnisotropicConfiguration {
  112987. private _isEnabled;
  112988. /**
  112989. * Defines if the anisotropy is enabled in the material.
  112990. */
  112991. isEnabled: boolean;
  112992. /**
  112993. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  112994. */
  112995. intensity: number;
  112996. /**
  112997. * Defines if the effect is along the tangents, bitangents or in between.
  112998. * By default, the effect is "strectching" the highlights along the tangents.
  112999. */
  113000. direction: Vector2;
  113001. private _texture;
  113002. /**
  113003. * Stores the anisotropy values in a texture.
  113004. * rg is direction (like normal from -1 to 1)
  113005. * b is a intensity
  113006. */
  113007. texture: Nullable<BaseTexture>;
  113008. /** @hidden */
  113009. private _internalMarkAllSubMeshesAsTexturesDirty;
  113010. /** @hidden */
  113011. _markAllSubMeshesAsTexturesDirty(): void;
  113012. /**
  113013. * Instantiate a new istance of anisotropy configuration.
  113014. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113015. */
  113016. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113017. /**
  113018. * Specifies that the submesh is ready to be used.
  113019. * @param defines the list of "defines" to update.
  113020. * @param scene defines the scene the material belongs to.
  113021. * @returns - boolean indicating that the submesh is ready or not.
  113022. */
  113023. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  113024. /**
  113025. * Checks to see if a texture is used in the material.
  113026. * @param defines the list of "defines" to update.
  113027. * @param mesh the mesh we are preparing the defines for.
  113028. * @param scene defines the scene the material belongs to.
  113029. */
  113030. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  113031. /**
  113032. * Binds the material data.
  113033. * @param uniformBuffer defines the Uniform buffer to fill in.
  113034. * @param scene defines the scene the material belongs to.
  113035. * @param isFrozen defines wether the material is frozen or not.
  113036. */
  113037. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113038. /**
  113039. * Checks to see if a texture is used in the material.
  113040. * @param texture - Base texture to use.
  113041. * @returns - Boolean specifying if a texture is used in the material.
  113042. */
  113043. hasTexture(texture: BaseTexture): boolean;
  113044. /**
  113045. * Returns an array of the actively used textures.
  113046. * @param activeTextures Array of BaseTextures
  113047. */
  113048. getActiveTextures(activeTextures: BaseTexture[]): void;
  113049. /**
  113050. * Returns the animatable textures.
  113051. * @param animatables Array of animatable textures.
  113052. */
  113053. getAnimatables(animatables: IAnimatable[]): void;
  113054. /**
  113055. * Disposes the resources of the material.
  113056. * @param forceDisposeTextures - Forces the disposal of all textures.
  113057. */
  113058. dispose(forceDisposeTextures?: boolean): void;
  113059. /**
  113060. * Get the current class name of the texture useful for serialization or dynamic coding.
  113061. * @returns "PBRAnisotropicConfiguration"
  113062. */
  113063. getClassName(): string;
  113064. /**
  113065. * Add fallbacks to the effect fallbacks list.
  113066. * @param defines defines the Base texture to use.
  113067. * @param fallbacks defines the current fallback list.
  113068. * @param currentRank defines the current fallback rank.
  113069. * @returns the new fallback rank.
  113070. */
  113071. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113072. /**
  113073. * Add the required uniforms to the current list.
  113074. * @param uniforms defines the current uniform list.
  113075. */
  113076. static AddUniforms(uniforms: string[]): void;
  113077. /**
  113078. * Add the required uniforms to the current buffer.
  113079. * @param uniformBuffer defines the current uniform buffer.
  113080. */
  113081. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113082. /**
  113083. * Add the required samplers to the current list.
  113084. * @param samplers defines the current sampler list.
  113085. */
  113086. static AddSamplers(samplers: string[]): void;
  113087. /**
  113088. * Makes a duplicate of the current configuration into another one.
  113089. * @param anisotropicConfiguration define the config where to copy the info
  113090. */
  113091. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  113092. /**
  113093. * Serializes this anisotropy configuration.
  113094. * @returns - An object with the serialized config.
  113095. */
  113096. serialize(): any;
  113097. /**
  113098. * Parses a anisotropy Configuration from a serialized object.
  113099. * @param source - Serialized object.
  113100. * @param scene Defines the scene we are parsing for
  113101. * @param rootUrl Defines the rootUrl to load from
  113102. */
  113103. parse(source: any, scene: Scene, rootUrl: string): void;
  113104. }
  113105. }
  113106. declare module BABYLON {
  113107. /**
  113108. * @hidden
  113109. */
  113110. export interface IMaterialBRDFDefines {
  113111. BRDF_V_HEIGHT_CORRELATED: boolean;
  113112. MS_BRDF_ENERGY_CONSERVATION: boolean;
  113113. SPHERICAL_HARMONICS: boolean;
  113114. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  113115. /** @hidden */
  113116. _areMiscDirty: boolean;
  113117. }
  113118. /**
  113119. * Define the code related to the BRDF parameters of the pbr material.
  113120. */
  113121. export class PBRBRDFConfiguration {
  113122. /**
  113123. * Default value used for the energy conservation.
  113124. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113125. */
  113126. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  113127. /**
  113128. * Default value used for the Smith Visibility Height Correlated mode.
  113129. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113130. */
  113131. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  113132. /**
  113133. * Default value used for the IBL diffuse part.
  113134. * This can help switching back to the polynomials mode globally which is a tiny bit
  113135. * less GPU intensive at the drawback of a lower quality.
  113136. */
  113137. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  113138. /**
  113139. * Default value used for activating energy conservation for the specular workflow.
  113140. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113141. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113142. */
  113143. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  113144. private _useEnergyConservation;
  113145. /**
  113146. * Defines if the material uses energy conservation.
  113147. */
  113148. useEnergyConservation: boolean;
  113149. private _useSmithVisibilityHeightCorrelated;
  113150. /**
  113151. * LEGACY Mode set to false
  113152. * Defines if the material uses height smith correlated visibility term.
  113153. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  113154. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  113155. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  113156. * Not relying on height correlated will also disable energy conservation.
  113157. */
  113158. useSmithVisibilityHeightCorrelated: boolean;
  113159. private _useSphericalHarmonics;
  113160. /**
  113161. * LEGACY Mode set to false
  113162. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  113163. * diffuse part of the IBL.
  113164. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  113165. * to the ground truth.
  113166. */
  113167. useSphericalHarmonics: boolean;
  113168. private _useSpecularGlossinessInputEnergyConservation;
  113169. /**
  113170. * Defines if the material uses energy conservation, when the specular workflow is active.
  113171. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113172. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113173. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  113174. */
  113175. useSpecularGlossinessInputEnergyConservation: boolean;
  113176. /** @hidden */
  113177. private _internalMarkAllSubMeshesAsMiscDirty;
  113178. /** @hidden */
  113179. _markAllSubMeshesAsMiscDirty(): void;
  113180. /**
  113181. * Instantiate a new istance of clear coat configuration.
  113182. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  113183. */
  113184. constructor(markAllSubMeshesAsMiscDirty: () => void);
  113185. /**
  113186. * Checks to see if a texture is used in the material.
  113187. * @param defines the list of "defines" to update.
  113188. */
  113189. prepareDefines(defines: IMaterialBRDFDefines): void;
  113190. /**
  113191. * Get the current class name of the texture useful for serialization or dynamic coding.
  113192. * @returns "PBRClearCoatConfiguration"
  113193. */
  113194. getClassName(): string;
  113195. /**
  113196. * Makes a duplicate of the current configuration into another one.
  113197. * @param brdfConfiguration define the config where to copy the info
  113198. */
  113199. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  113200. /**
  113201. * Serializes this BRDF configuration.
  113202. * @returns - An object with the serialized config.
  113203. */
  113204. serialize(): any;
  113205. /**
  113206. * Parses a anisotropy Configuration from a serialized object.
  113207. * @param source - Serialized object.
  113208. * @param scene Defines the scene we are parsing for
  113209. * @param rootUrl Defines the rootUrl to load from
  113210. */
  113211. parse(source: any, scene: Scene, rootUrl: string): void;
  113212. }
  113213. }
  113214. declare module BABYLON {
  113215. /**
  113216. * @hidden
  113217. */
  113218. export interface IMaterialSheenDefines {
  113219. SHEEN: boolean;
  113220. SHEEN_TEXTURE: boolean;
  113221. SHEEN_TEXTUREDIRECTUV: number;
  113222. SHEEN_LINKWITHALBEDO: boolean;
  113223. /** @hidden */
  113224. _areTexturesDirty: boolean;
  113225. }
  113226. /**
  113227. * Define the code related to the Sheen parameters of the pbr material.
  113228. */
  113229. export class PBRSheenConfiguration {
  113230. private _isEnabled;
  113231. /**
  113232. * Defines if the material uses sheen.
  113233. */
  113234. isEnabled: boolean;
  113235. private _linkSheenWithAlbedo;
  113236. /**
  113237. * Defines if the sheen is linked to the sheen color.
  113238. */
  113239. linkSheenWithAlbedo: boolean;
  113240. /**
  113241. * Defines the sheen intensity.
  113242. */
  113243. intensity: number;
  113244. /**
  113245. * Defines the sheen color.
  113246. */
  113247. color: Color3;
  113248. private _texture;
  113249. /**
  113250. * Stores the sheen tint values in a texture.
  113251. * rgb is tint
  113252. * a is a intensity
  113253. */
  113254. texture: Nullable<BaseTexture>;
  113255. /** @hidden */
  113256. private _internalMarkAllSubMeshesAsTexturesDirty;
  113257. /** @hidden */
  113258. _markAllSubMeshesAsTexturesDirty(): void;
  113259. /**
  113260. * Instantiate a new istance of clear coat configuration.
  113261. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113262. */
  113263. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113264. /**
  113265. * Specifies that the submesh is ready to be used.
  113266. * @param defines the list of "defines" to update.
  113267. * @param scene defines the scene the material belongs to.
  113268. * @returns - boolean indicating that the submesh is ready or not.
  113269. */
  113270. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  113271. /**
  113272. * Checks to see if a texture is used in the material.
  113273. * @param defines the list of "defines" to update.
  113274. * @param scene defines the scene the material belongs to.
  113275. */
  113276. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  113277. /**
  113278. * Binds the material data.
  113279. * @param uniformBuffer defines the Uniform buffer to fill in.
  113280. * @param scene defines the scene the material belongs to.
  113281. * @param isFrozen defines wether the material is frozen or not.
  113282. */
  113283. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113284. /**
  113285. * Checks to see if a texture is used in the material.
  113286. * @param texture - Base texture to use.
  113287. * @returns - Boolean specifying if a texture is used in the material.
  113288. */
  113289. hasTexture(texture: BaseTexture): boolean;
  113290. /**
  113291. * Returns an array of the actively used textures.
  113292. * @param activeTextures Array of BaseTextures
  113293. */
  113294. getActiveTextures(activeTextures: BaseTexture[]): void;
  113295. /**
  113296. * Returns the animatable textures.
  113297. * @param animatables Array of animatable textures.
  113298. */
  113299. getAnimatables(animatables: IAnimatable[]): void;
  113300. /**
  113301. * Disposes the resources of the material.
  113302. * @param forceDisposeTextures - Forces the disposal of all textures.
  113303. */
  113304. dispose(forceDisposeTextures?: boolean): void;
  113305. /**
  113306. * Get the current class name of the texture useful for serialization or dynamic coding.
  113307. * @returns "PBRSheenConfiguration"
  113308. */
  113309. getClassName(): string;
  113310. /**
  113311. * Add fallbacks to the effect fallbacks list.
  113312. * @param defines defines the Base texture to use.
  113313. * @param fallbacks defines the current fallback list.
  113314. * @param currentRank defines the current fallback rank.
  113315. * @returns the new fallback rank.
  113316. */
  113317. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113318. /**
  113319. * Add the required uniforms to the current list.
  113320. * @param uniforms defines the current uniform list.
  113321. */
  113322. static AddUniforms(uniforms: string[]): void;
  113323. /**
  113324. * Add the required uniforms to the current buffer.
  113325. * @param uniformBuffer defines the current uniform buffer.
  113326. */
  113327. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113328. /**
  113329. * Add the required samplers to the current list.
  113330. * @param samplers defines the current sampler list.
  113331. */
  113332. static AddSamplers(samplers: string[]): void;
  113333. /**
  113334. * Makes a duplicate of the current configuration into another one.
  113335. * @param sheenConfiguration define the config where to copy the info
  113336. */
  113337. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  113338. /**
  113339. * Serializes this BRDF configuration.
  113340. * @returns - An object with the serialized config.
  113341. */
  113342. serialize(): any;
  113343. /**
  113344. * Parses a anisotropy Configuration from a serialized object.
  113345. * @param source - Serialized object.
  113346. * @param scene Defines the scene we are parsing for
  113347. * @param rootUrl Defines the rootUrl to load from
  113348. */
  113349. parse(source: any, scene: Scene, rootUrl: string): void;
  113350. }
  113351. }
  113352. declare module BABYLON {
  113353. /**
  113354. * @hidden
  113355. */
  113356. export interface IMaterialSubSurfaceDefines {
  113357. SUBSURFACE: boolean;
  113358. SS_REFRACTION: boolean;
  113359. SS_TRANSLUCENCY: boolean;
  113360. SS_SCATERRING: boolean;
  113361. SS_THICKNESSANDMASK_TEXTURE: boolean;
  113362. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  113363. SS_REFRACTIONMAP_3D: boolean;
  113364. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  113365. SS_LODINREFRACTIONALPHA: boolean;
  113366. SS_GAMMAREFRACTION: boolean;
  113367. SS_RGBDREFRACTION: boolean;
  113368. SS_LINEARSPECULARREFRACTION: boolean;
  113369. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  113370. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  113371. /** @hidden */
  113372. _areTexturesDirty: boolean;
  113373. }
  113374. /**
  113375. * Define the code related to the sub surface parameters of the pbr material.
  113376. */
  113377. export class PBRSubSurfaceConfiguration {
  113378. private _isRefractionEnabled;
  113379. /**
  113380. * Defines if the refraction is enabled in the material.
  113381. */
  113382. isRefractionEnabled: boolean;
  113383. private _isTranslucencyEnabled;
  113384. /**
  113385. * Defines if the translucency is enabled in the material.
  113386. */
  113387. isTranslucencyEnabled: boolean;
  113388. private _isScatteringEnabled;
  113389. /**
  113390. * Defines the refraction intensity of the material.
  113391. * The refraction when enabled replaces the Diffuse part of the material.
  113392. * The intensity helps transitionning between diffuse and refraction.
  113393. */
  113394. refractionIntensity: number;
  113395. /**
  113396. * Defines the translucency intensity of the material.
  113397. * When translucency has been enabled, this defines how much of the "translucency"
  113398. * is addded to the diffuse part of the material.
  113399. */
  113400. translucencyIntensity: number;
  113401. /**
  113402. * Defines the scattering intensity of the material.
  113403. * When scattering has been enabled, this defines how much of the "scattered light"
  113404. * is addded to the diffuse part of the material.
  113405. */
  113406. scatteringIntensity: number;
  113407. private _thicknessTexture;
  113408. /**
  113409. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  113410. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  113411. * 0 would mean minimumThickness
  113412. * 1 would mean maximumThickness
  113413. * The other channels might be use as a mask to vary the different effects intensity.
  113414. */
  113415. thicknessTexture: Nullable<BaseTexture>;
  113416. private _refractionTexture;
  113417. /**
  113418. * Defines the texture to use for refraction.
  113419. */
  113420. refractionTexture: Nullable<BaseTexture>;
  113421. private _indexOfRefraction;
  113422. /**
  113423. * Defines the index of refraction used in the material.
  113424. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  113425. */
  113426. indexOfRefraction: number;
  113427. private _invertRefractionY;
  113428. /**
  113429. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113430. */
  113431. invertRefractionY: boolean;
  113432. private _linkRefractionWithTransparency;
  113433. /**
  113434. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113435. * Materials half opaque for instance using refraction could benefit from this control.
  113436. */
  113437. linkRefractionWithTransparency: boolean;
  113438. /**
  113439. * Defines the minimum thickness stored in the thickness map.
  113440. * If no thickness map is defined, this value will be used to simulate thickness.
  113441. */
  113442. minimumThickness: number;
  113443. /**
  113444. * Defines the maximum thickness stored in the thickness map.
  113445. */
  113446. maximumThickness: number;
  113447. /**
  113448. * Defines the volume tint of the material.
  113449. * This is used for both translucency and scattering.
  113450. */
  113451. tintColor: Color3;
  113452. /**
  113453. * Defines the distance at which the tint color should be found in the media.
  113454. * This is used for refraction only.
  113455. */
  113456. tintColorAtDistance: number;
  113457. /**
  113458. * Defines how far each channel transmit through the media.
  113459. * It is defined as a color to simplify it selection.
  113460. */
  113461. diffusionDistance: Color3;
  113462. private _useMaskFromThicknessTexture;
  113463. /**
  113464. * Stores the intensity of the different subsurface effects in the thickness texture.
  113465. * * the green channel is the translucency intensity.
  113466. * * the blue channel is the scattering intensity.
  113467. * * the alpha channel is the refraction intensity.
  113468. */
  113469. useMaskFromThicknessTexture: boolean;
  113470. /** @hidden */
  113471. private _internalMarkAllSubMeshesAsTexturesDirty;
  113472. /** @hidden */
  113473. _markAllSubMeshesAsTexturesDirty(): void;
  113474. /**
  113475. * Instantiate a new istance of sub surface configuration.
  113476. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113477. */
  113478. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113479. /**
  113480. * Gets wehter the submesh is ready to be used or not.
  113481. * @param defines the list of "defines" to update.
  113482. * @param scene defines the scene the material belongs to.
  113483. * @returns - boolean indicating that the submesh is ready or not.
  113484. */
  113485. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  113486. /**
  113487. * Checks to see if a texture is used in the material.
  113488. * @param defines the list of "defines" to update.
  113489. * @param scene defines the scene to the material belongs to.
  113490. */
  113491. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  113492. /**
  113493. * Binds the material data.
  113494. * @param uniformBuffer defines the Uniform buffer to fill in.
  113495. * @param scene defines the scene the material belongs to.
  113496. * @param engine defines the engine the material belongs to.
  113497. * @param isFrozen defines wether the material is frozen or not.
  113498. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  113499. */
  113500. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  113501. /**
  113502. * Unbinds the material from the mesh.
  113503. * @param activeEffect defines the effect that should be unbound from.
  113504. * @returns true if unbound, otherwise false
  113505. */
  113506. unbind(activeEffect: Effect): boolean;
  113507. /**
  113508. * Returns the texture used for refraction or null if none is used.
  113509. * @param scene defines the scene the material belongs to.
  113510. * @returns - Refraction texture if present. If no refraction texture and refraction
  113511. * is linked with transparency, returns environment texture. Otherwise, returns null.
  113512. */
  113513. private _getRefractionTexture;
  113514. /**
  113515. * Returns true if alpha blending should be disabled.
  113516. */
  113517. readonly disableAlphaBlending: boolean;
  113518. /**
  113519. * Fills the list of render target textures.
  113520. * @param renderTargets the list of render targets to update
  113521. */
  113522. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  113523. /**
  113524. * Checks to see if a texture is used in the material.
  113525. * @param texture - Base texture to use.
  113526. * @returns - Boolean specifying if a texture is used in the material.
  113527. */
  113528. hasTexture(texture: BaseTexture): boolean;
  113529. /**
  113530. * Gets a boolean indicating that current material needs to register RTT
  113531. * @returns true if this uses a render target otherwise false.
  113532. */
  113533. hasRenderTargetTextures(): boolean;
  113534. /**
  113535. * Returns an array of the actively used textures.
  113536. * @param activeTextures Array of BaseTextures
  113537. */
  113538. getActiveTextures(activeTextures: BaseTexture[]): void;
  113539. /**
  113540. * Returns the animatable textures.
  113541. * @param animatables Array of animatable textures.
  113542. */
  113543. getAnimatables(animatables: IAnimatable[]): void;
  113544. /**
  113545. * Disposes the resources of the material.
  113546. * @param forceDisposeTextures - Forces the disposal of all textures.
  113547. */
  113548. dispose(forceDisposeTextures?: boolean): void;
  113549. /**
  113550. * Get the current class name of the texture useful for serialization or dynamic coding.
  113551. * @returns "PBRSubSurfaceConfiguration"
  113552. */
  113553. getClassName(): string;
  113554. /**
  113555. * Add fallbacks to the effect fallbacks list.
  113556. * @param defines defines the Base texture to use.
  113557. * @param fallbacks defines the current fallback list.
  113558. * @param currentRank defines the current fallback rank.
  113559. * @returns the new fallback rank.
  113560. */
  113561. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113562. /**
  113563. * Add the required uniforms to the current list.
  113564. * @param uniforms defines the current uniform list.
  113565. */
  113566. static AddUniforms(uniforms: string[]): void;
  113567. /**
  113568. * Add the required samplers to the current list.
  113569. * @param samplers defines the current sampler list.
  113570. */
  113571. static AddSamplers(samplers: string[]): void;
  113572. /**
  113573. * Add the required uniforms to the current buffer.
  113574. * @param uniformBuffer defines the current uniform buffer.
  113575. */
  113576. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113577. /**
  113578. * Makes a duplicate of the current configuration into another one.
  113579. * @param configuration define the config where to copy the info
  113580. */
  113581. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  113582. /**
  113583. * Serializes this Sub Surface configuration.
  113584. * @returns - An object with the serialized config.
  113585. */
  113586. serialize(): any;
  113587. /**
  113588. * Parses a anisotropy Configuration from a serialized object.
  113589. * @param source - Serialized object.
  113590. * @param scene Defines the scene we are parsing for
  113591. * @param rootUrl Defines the rootUrl to load from
  113592. */
  113593. parse(source: any, scene: Scene, rootUrl: string): void;
  113594. }
  113595. }
  113596. declare module BABYLON {
  113597. /** @hidden */
  113598. export var pbrFragmentDeclaration: {
  113599. name: string;
  113600. shader: string;
  113601. };
  113602. }
  113603. declare module BABYLON {
  113604. /** @hidden */
  113605. export var pbrUboDeclaration: {
  113606. name: string;
  113607. shader: string;
  113608. };
  113609. }
  113610. declare module BABYLON {
  113611. /** @hidden */
  113612. export var pbrFragmentExtraDeclaration: {
  113613. name: string;
  113614. shader: string;
  113615. };
  113616. }
  113617. declare module BABYLON {
  113618. /** @hidden */
  113619. export var pbrFragmentSamplersDeclaration: {
  113620. name: string;
  113621. shader: string;
  113622. };
  113623. }
  113624. declare module BABYLON {
  113625. /** @hidden */
  113626. export var pbrHelperFunctions: {
  113627. name: string;
  113628. shader: string;
  113629. };
  113630. }
  113631. declare module BABYLON {
  113632. /** @hidden */
  113633. export var harmonicsFunctions: {
  113634. name: string;
  113635. shader: string;
  113636. };
  113637. }
  113638. declare module BABYLON {
  113639. /** @hidden */
  113640. export var pbrDirectLightingSetupFunctions: {
  113641. name: string;
  113642. shader: string;
  113643. };
  113644. }
  113645. declare module BABYLON {
  113646. /** @hidden */
  113647. export var pbrDirectLightingFalloffFunctions: {
  113648. name: string;
  113649. shader: string;
  113650. };
  113651. }
  113652. declare module BABYLON {
  113653. /** @hidden */
  113654. export var pbrBRDFFunctions: {
  113655. name: string;
  113656. shader: string;
  113657. };
  113658. }
  113659. declare module BABYLON {
  113660. /** @hidden */
  113661. export var pbrDirectLightingFunctions: {
  113662. name: string;
  113663. shader: string;
  113664. };
  113665. }
  113666. declare module BABYLON {
  113667. /** @hidden */
  113668. export var pbrIBLFunctions: {
  113669. name: string;
  113670. shader: string;
  113671. };
  113672. }
  113673. declare module BABYLON {
  113674. /** @hidden */
  113675. export var pbrDebug: {
  113676. name: string;
  113677. shader: string;
  113678. };
  113679. }
  113680. declare module BABYLON {
  113681. /** @hidden */
  113682. export var pbrPixelShader: {
  113683. name: string;
  113684. shader: string;
  113685. };
  113686. }
  113687. declare module BABYLON {
  113688. /** @hidden */
  113689. export var pbrVertexDeclaration: {
  113690. name: string;
  113691. shader: string;
  113692. };
  113693. }
  113694. declare module BABYLON {
  113695. /** @hidden */
  113696. export var pbrVertexShader: {
  113697. name: string;
  113698. shader: string;
  113699. };
  113700. }
  113701. declare module BABYLON {
  113702. /**
  113703. * Manages the defines for the PBR Material.
  113704. * @hidden
  113705. */
  113706. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  113707. PBR: boolean;
  113708. MAINUV1: boolean;
  113709. MAINUV2: boolean;
  113710. UV1: boolean;
  113711. UV2: boolean;
  113712. ALBEDO: boolean;
  113713. ALBEDODIRECTUV: number;
  113714. VERTEXCOLOR: boolean;
  113715. AMBIENT: boolean;
  113716. AMBIENTDIRECTUV: number;
  113717. AMBIENTINGRAYSCALE: boolean;
  113718. OPACITY: boolean;
  113719. VERTEXALPHA: boolean;
  113720. OPACITYDIRECTUV: number;
  113721. OPACITYRGB: boolean;
  113722. ALPHATEST: boolean;
  113723. DEPTHPREPASS: boolean;
  113724. ALPHABLEND: boolean;
  113725. ALPHAFROMALBEDO: boolean;
  113726. ALPHATESTVALUE: string;
  113727. SPECULAROVERALPHA: boolean;
  113728. RADIANCEOVERALPHA: boolean;
  113729. ALPHAFRESNEL: boolean;
  113730. LINEARALPHAFRESNEL: boolean;
  113731. PREMULTIPLYALPHA: boolean;
  113732. EMISSIVE: boolean;
  113733. EMISSIVEDIRECTUV: number;
  113734. REFLECTIVITY: boolean;
  113735. REFLECTIVITYDIRECTUV: number;
  113736. SPECULARTERM: boolean;
  113737. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  113738. MICROSURFACEAUTOMATIC: boolean;
  113739. LODBASEDMICROSFURACE: boolean;
  113740. MICROSURFACEMAP: boolean;
  113741. MICROSURFACEMAPDIRECTUV: number;
  113742. METALLICWORKFLOW: boolean;
  113743. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  113744. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  113745. METALLNESSSTOREINMETALMAPBLUE: boolean;
  113746. AOSTOREINMETALMAPRED: boolean;
  113747. ENVIRONMENTBRDF: boolean;
  113748. ENVIRONMENTBRDF_RGBD: boolean;
  113749. NORMAL: boolean;
  113750. TANGENT: boolean;
  113751. BUMP: boolean;
  113752. BUMPDIRECTUV: number;
  113753. OBJECTSPACE_NORMALMAP: boolean;
  113754. PARALLAX: boolean;
  113755. PARALLAXOCCLUSION: boolean;
  113756. NORMALXYSCALE: boolean;
  113757. LIGHTMAP: boolean;
  113758. LIGHTMAPDIRECTUV: number;
  113759. USELIGHTMAPASSHADOWMAP: boolean;
  113760. GAMMALIGHTMAP: boolean;
  113761. RGBDLIGHTMAP: boolean;
  113762. REFLECTION: boolean;
  113763. REFLECTIONMAP_3D: boolean;
  113764. REFLECTIONMAP_SPHERICAL: boolean;
  113765. REFLECTIONMAP_PLANAR: boolean;
  113766. REFLECTIONMAP_CUBIC: boolean;
  113767. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  113768. REFLECTIONMAP_PROJECTION: boolean;
  113769. REFLECTIONMAP_SKYBOX: boolean;
  113770. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  113771. REFLECTIONMAP_EXPLICIT: boolean;
  113772. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  113773. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  113774. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  113775. INVERTCUBICMAP: boolean;
  113776. USESPHERICALFROMREFLECTIONMAP: boolean;
  113777. USEIRRADIANCEMAP: boolean;
  113778. SPHERICAL_HARMONICS: boolean;
  113779. USESPHERICALINVERTEX: boolean;
  113780. REFLECTIONMAP_OPPOSITEZ: boolean;
  113781. LODINREFLECTIONALPHA: boolean;
  113782. GAMMAREFLECTION: boolean;
  113783. RGBDREFLECTION: boolean;
  113784. LINEARSPECULARREFLECTION: boolean;
  113785. RADIANCEOCCLUSION: boolean;
  113786. HORIZONOCCLUSION: boolean;
  113787. INSTANCES: boolean;
  113788. NUM_BONE_INFLUENCERS: number;
  113789. BonesPerMesh: number;
  113790. BONETEXTURE: boolean;
  113791. NONUNIFORMSCALING: boolean;
  113792. MORPHTARGETS: boolean;
  113793. MORPHTARGETS_NORMAL: boolean;
  113794. MORPHTARGETS_TANGENT: boolean;
  113795. MORPHTARGETS_UV: boolean;
  113796. NUM_MORPH_INFLUENCERS: number;
  113797. IMAGEPROCESSING: boolean;
  113798. VIGNETTE: boolean;
  113799. VIGNETTEBLENDMODEMULTIPLY: boolean;
  113800. VIGNETTEBLENDMODEOPAQUE: boolean;
  113801. TONEMAPPING: boolean;
  113802. TONEMAPPING_ACES: boolean;
  113803. CONTRAST: boolean;
  113804. COLORCURVES: boolean;
  113805. COLORGRADING: boolean;
  113806. COLORGRADING3D: boolean;
  113807. SAMPLER3DGREENDEPTH: boolean;
  113808. SAMPLER3DBGRMAP: boolean;
  113809. IMAGEPROCESSINGPOSTPROCESS: boolean;
  113810. EXPOSURE: boolean;
  113811. MULTIVIEW: boolean;
  113812. USEPHYSICALLIGHTFALLOFF: boolean;
  113813. USEGLTFLIGHTFALLOFF: boolean;
  113814. TWOSIDEDLIGHTING: boolean;
  113815. SHADOWFLOAT: boolean;
  113816. CLIPPLANE: boolean;
  113817. CLIPPLANE2: boolean;
  113818. CLIPPLANE3: boolean;
  113819. CLIPPLANE4: boolean;
  113820. POINTSIZE: boolean;
  113821. FOG: boolean;
  113822. LOGARITHMICDEPTH: boolean;
  113823. FORCENORMALFORWARD: boolean;
  113824. SPECULARAA: boolean;
  113825. CLEARCOAT: boolean;
  113826. CLEARCOAT_DEFAULTIOR: boolean;
  113827. CLEARCOAT_TEXTURE: boolean;
  113828. CLEARCOAT_TEXTUREDIRECTUV: number;
  113829. CLEARCOAT_BUMP: boolean;
  113830. CLEARCOAT_BUMPDIRECTUV: number;
  113831. CLEARCOAT_TINT: boolean;
  113832. CLEARCOAT_TINT_TEXTURE: boolean;
  113833. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  113834. ANISOTROPIC: boolean;
  113835. ANISOTROPIC_TEXTURE: boolean;
  113836. ANISOTROPIC_TEXTUREDIRECTUV: number;
  113837. BRDF_V_HEIGHT_CORRELATED: boolean;
  113838. MS_BRDF_ENERGY_CONSERVATION: boolean;
  113839. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  113840. SHEEN: boolean;
  113841. SHEEN_TEXTURE: boolean;
  113842. SHEEN_TEXTUREDIRECTUV: number;
  113843. SHEEN_LINKWITHALBEDO: boolean;
  113844. SUBSURFACE: boolean;
  113845. SS_REFRACTION: boolean;
  113846. SS_TRANSLUCENCY: boolean;
  113847. SS_SCATERRING: boolean;
  113848. SS_THICKNESSANDMASK_TEXTURE: boolean;
  113849. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  113850. SS_REFRACTIONMAP_3D: boolean;
  113851. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  113852. SS_LODINREFRACTIONALPHA: boolean;
  113853. SS_GAMMAREFRACTION: boolean;
  113854. SS_RGBDREFRACTION: boolean;
  113855. SS_LINEARSPECULARREFRACTION: boolean;
  113856. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  113857. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  113858. UNLIT: boolean;
  113859. DEBUGMODE: number;
  113860. /**
  113861. * Initializes the PBR Material defines.
  113862. */
  113863. constructor();
  113864. /**
  113865. * Resets the PBR Material defines.
  113866. */
  113867. reset(): void;
  113868. }
  113869. /**
  113870. * The Physically based material base class of BJS.
  113871. *
  113872. * This offers the main features of a standard PBR material.
  113873. * For more information, please refer to the documentation :
  113874. * https://doc.babylonjs.com/how_to/physically_based_rendering
  113875. */
  113876. export abstract class PBRBaseMaterial extends PushMaterial {
  113877. /**
  113878. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  113879. */
  113880. static readonly PBRMATERIAL_OPAQUE: number;
  113881. /**
  113882. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  113883. */
  113884. static readonly PBRMATERIAL_ALPHATEST: number;
  113885. /**
  113886. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113887. */
  113888. static readonly PBRMATERIAL_ALPHABLEND: number;
  113889. /**
  113890. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113891. * They are also discarded below the alpha cutoff threshold to improve performances.
  113892. */
  113893. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  113894. /**
  113895. * Defines the default value of how much AO map is occluding the analytical lights
  113896. * (point spot...).
  113897. */
  113898. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  113899. /**
  113900. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  113901. */
  113902. static readonly LIGHTFALLOFF_PHYSICAL: number;
  113903. /**
  113904. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  113905. * to enhance interoperability with other engines.
  113906. */
  113907. static readonly LIGHTFALLOFF_GLTF: number;
  113908. /**
  113909. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  113910. * to enhance interoperability with other materials.
  113911. */
  113912. static readonly LIGHTFALLOFF_STANDARD: number;
  113913. /**
  113914. * Intensity of the direct lights e.g. the four lights available in your scene.
  113915. * This impacts both the direct diffuse and specular highlights.
  113916. */
  113917. protected _directIntensity: number;
  113918. /**
  113919. * Intensity of the emissive part of the material.
  113920. * This helps controlling the emissive effect without modifying the emissive color.
  113921. */
  113922. protected _emissiveIntensity: number;
  113923. /**
  113924. * Intensity of the environment e.g. how much the environment will light the object
  113925. * either through harmonics for rough material or through the refelction for shiny ones.
  113926. */
  113927. protected _environmentIntensity: number;
  113928. /**
  113929. * This is a special control allowing the reduction of the specular highlights coming from the
  113930. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  113931. */
  113932. protected _specularIntensity: number;
  113933. /**
  113934. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  113935. */
  113936. private _lightingInfos;
  113937. /**
  113938. * Debug Control allowing disabling the bump map on this material.
  113939. */
  113940. protected _disableBumpMap: boolean;
  113941. /**
  113942. * AKA Diffuse Texture in standard nomenclature.
  113943. */
  113944. protected _albedoTexture: Nullable<BaseTexture>;
  113945. /**
  113946. * AKA Occlusion Texture in other nomenclature.
  113947. */
  113948. protected _ambientTexture: Nullable<BaseTexture>;
  113949. /**
  113950. * AKA Occlusion Texture Intensity in other nomenclature.
  113951. */
  113952. protected _ambientTextureStrength: number;
  113953. /**
  113954. * Defines how much the AO map is occluding the analytical lights (point spot...).
  113955. * 1 means it completely occludes it
  113956. * 0 mean it has no impact
  113957. */
  113958. protected _ambientTextureImpactOnAnalyticalLights: number;
  113959. /**
  113960. * Stores the alpha values in a texture.
  113961. */
  113962. protected _opacityTexture: Nullable<BaseTexture>;
  113963. /**
  113964. * Stores the reflection values in a texture.
  113965. */
  113966. protected _reflectionTexture: Nullable<BaseTexture>;
  113967. /**
  113968. * Stores the emissive values in a texture.
  113969. */
  113970. protected _emissiveTexture: Nullable<BaseTexture>;
  113971. /**
  113972. * AKA Specular texture in other nomenclature.
  113973. */
  113974. protected _reflectivityTexture: Nullable<BaseTexture>;
  113975. /**
  113976. * Used to switch from specular/glossiness to metallic/roughness workflow.
  113977. */
  113978. protected _metallicTexture: Nullable<BaseTexture>;
  113979. /**
  113980. * Specifies the metallic scalar of the metallic/roughness workflow.
  113981. * Can also be used to scale the metalness values of the metallic texture.
  113982. */
  113983. protected _metallic: Nullable<number>;
  113984. /**
  113985. * Specifies the roughness scalar of the metallic/roughness workflow.
  113986. * Can also be used to scale the roughness values of the metallic texture.
  113987. */
  113988. protected _roughness: Nullable<number>;
  113989. /**
  113990. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  113991. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  113992. */
  113993. protected _microSurfaceTexture: Nullable<BaseTexture>;
  113994. /**
  113995. * Stores surface normal data used to displace a mesh in a texture.
  113996. */
  113997. protected _bumpTexture: Nullable<BaseTexture>;
  113998. /**
  113999. * Stores the pre-calculated light information of a mesh in a texture.
  114000. */
  114001. protected _lightmapTexture: Nullable<BaseTexture>;
  114002. /**
  114003. * The color of a material in ambient lighting.
  114004. */
  114005. protected _ambientColor: Color3;
  114006. /**
  114007. * AKA Diffuse Color in other nomenclature.
  114008. */
  114009. protected _albedoColor: Color3;
  114010. /**
  114011. * AKA Specular Color in other nomenclature.
  114012. */
  114013. protected _reflectivityColor: Color3;
  114014. /**
  114015. * The color applied when light is reflected from a material.
  114016. */
  114017. protected _reflectionColor: Color3;
  114018. /**
  114019. * The color applied when light is emitted from a material.
  114020. */
  114021. protected _emissiveColor: Color3;
  114022. /**
  114023. * AKA Glossiness in other nomenclature.
  114024. */
  114025. protected _microSurface: number;
  114026. /**
  114027. * Specifies that the material will use the light map as a show map.
  114028. */
  114029. protected _useLightmapAsShadowmap: boolean;
  114030. /**
  114031. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  114032. * makes the reflect vector face the model (under horizon).
  114033. */
  114034. protected _useHorizonOcclusion: boolean;
  114035. /**
  114036. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  114037. * too much the area relying on ambient texture to define their ambient occlusion.
  114038. */
  114039. protected _useRadianceOcclusion: boolean;
  114040. /**
  114041. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114042. */
  114043. protected _useAlphaFromAlbedoTexture: boolean;
  114044. /**
  114045. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  114046. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114047. */
  114048. protected _useSpecularOverAlpha: boolean;
  114049. /**
  114050. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114051. */
  114052. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114053. /**
  114054. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  114055. */
  114056. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  114057. /**
  114058. * Specifies if the metallic texture contains the roughness information in its green channel.
  114059. */
  114060. protected _useRoughnessFromMetallicTextureGreen: boolean;
  114061. /**
  114062. * Specifies if the metallic texture contains the metallness information in its blue channel.
  114063. */
  114064. protected _useMetallnessFromMetallicTextureBlue: boolean;
  114065. /**
  114066. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  114067. */
  114068. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  114069. /**
  114070. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  114071. */
  114072. protected _useAmbientInGrayScale: boolean;
  114073. /**
  114074. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  114075. * The material will try to infer what glossiness each pixel should be.
  114076. */
  114077. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  114078. /**
  114079. * Defines the falloff type used in this material.
  114080. * It by default is Physical.
  114081. */
  114082. protected _lightFalloff: number;
  114083. /**
  114084. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  114085. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  114086. */
  114087. protected _useRadianceOverAlpha: boolean;
  114088. /**
  114089. * Allows using an object space normal map (instead of tangent space).
  114090. */
  114091. protected _useObjectSpaceNormalMap: boolean;
  114092. /**
  114093. * Allows using the bump map in parallax mode.
  114094. */
  114095. protected _useParallax: boolean;
  114096. /**
  114097. * Allows using the bump map in parallax occlusion mode.
  114098. */
  114099. protected _useParallaxOcclusion: boolean;
  114100. /**
  114101. * Controls the scale bias of the parallax mode.
  114102. */
  114103. protected _parallaxScaleBias: number;
  114104. /**
  114105. * If sets to true, disables all the lights affecting the material.
  114106. */
  114107. protected _disableLighting: boolean;
  114108. /**
  114109. * Number of Simultaneous lights allowed on the material.
  114110. */
  114111. protected _maxSimultaneousLights: number;
  114112. /**
  114113. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  114114. */
  114115. protected _invertNormalMapX: boolean;
  114116. /**
  114117. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  114118. */
  114119. protected _invertNormalMapY: boolean;
  114120. /**
  114121. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114122. */
  114123. protected _twoSidedLighting: boolean;
  114124. /**
  114125. * Defines the alpha limits in alpha test mode.
  114126. */
  114127. protected _alphaCutOff: number;
  114128. /**
  114129. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114130. */
  114131. protected _forceAlphaTest: boolean;
  114132. /**
  114133. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114134. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  114135. */
  114136. protected _useAlphaFresnel: boolean;
  114137. /**
  114138. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114139. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  114140. */
  114141. protected _useLinearAlphaFresnel: boolean;
  114142. /**
  114143. * The transparency mode of the material.
  114144. */
  114145. protected _transparencyMode: Nullable<number>;
  114146. /**
  114147. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  114148. * from cos thetav and roughness:
  114149. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  114150. */
  114151. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  114152. /**
  114153. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  114154. */
  114155. protected _forceIrradianceInFragment: boolean;
  114156. /**
  114157. * Force normal to face away from face.
  114158. */
  114159. protected _forceNormalForward: boolean;
  114160. /**
  114161. * Enables specular anti aliasing in the PBR shader.
  114162. * It will both interacts on the Geometry for analytical and IBL lighting.
  114163. * It also prefilter the roughness map based on the bump values.
  114164. */
  114165. protected _enableSpecularAntiAliasing: boolean;
  114166. /**
  114167. * Default configuration related to image processing available in the PBR Material.
  114168. */
  114169. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114170. /**
  114171. * Keep track of the image processing observer to allow dispose and replace.
  114172. */
  114173. private _imageProcessingObserver;
  114174. /**
  114175. * Attaches a new image processing configuration to the PBR Material.
  114176. * @param configuration
  114177. */
  114178. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114179. /**
  114180. * Stores the available render targets.
  114181. */
  114182. private _renderTargets;
  114183. /**
  114184. * Sets the global ambient color for the material used in lighting calculations.
  114185. */
  114186. private _globalAmbientColor;
  114187. /**
  114188. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  114189. */
  114190. private _useLogarithmicDepth;
  114191. /**
  114192. * If set to true, no lighting calculations will be applied.
  114193. */
  114194. private _unlit;
  114195. private _debugMode;
  114196. /**
  114197. * @hidden
  114198. * This is reserved for the inspector.
  114199. * Defines the material debug mode.
  114200. * It helps seeing only some components of the material while troubleshooting.
  114201. */
  114202. debugMode: number;
  114203. /**
  114204. * @hidden
  114205. * This is reserved for the inspector.
  114206. * Specify from where on screen the debug mode should start.
  114207. * The value goes from -1 (full screen) to 1 (not visible)
  114208. * It helps with side by side comparison against the final render
  114209. * This defaults to -1
  114210. */
  114211. private debugLimit;
  114212. /**
  114213. * @hidden
  114214. * This is reserved for the inspector.
  114215. * As the default viewing range might not be enough (if the ambient is really small for instance)
  114216. * You can use the factor to better multiply the final value.
  114217. */
  114218. private debugFactor;
  114219. /**
  114220. * Defines the clear coat layer parameters for the material.
  114221. */
  114222. readonly clearCoat: PBRClearCoatConfiguration;
  114223. /**
  114224. * Defines the anisotropic parameters for the material.
  114225. */
  114226. readonly anisotropy: PBRAnisotropicConfiguration;
  114227. /**
  114228. * Defines the BRDF parameters for the material.
  114229. */
  114230. readonly brdf: PBRBRDFConfiguration;
  114231. /**
  114232. * Defines the Sheen parameters for the material.
  114233. */
  114234. readonly sheen: PBRSheenConfiguration;
  114235. /**
  114236. * Defines the SubSurface parameters for the material.
  114237. */
  114238. readonly subSurface: PBRSubSurfaceConfiguration;
  114239. /**
  114240. * Custom callback helping to override the default shader used in the material.
  114241. */
  114242. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  114243. protected _rebuildInParallel: boolean;
  114244. /**
  114245. * Instantiates a new PBRMaterial instance.
  114246. *
  114247. * @param name The material name
  114248. * @param scene The scene the material will be use in.
  114249. */
  114250. constructor(name: string, scene: Scene);
  114251. /**
  114252. * Gets a boolean indicating that current material needs to register RTT
  114253. */
  114254. readonly hasRenderTargetTextures: boolean;
  114255. /**
  114256. * Gets the name of the material class.
  114257. */
  114258. getClassName(): string;
  114259. /**
  114260. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114261. */
  114262. /**
  114263. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114264. */
  114265. useLogarithmicDepth: boolean;
  114266. /**
  114267. * Gets the current transparency mode.
  114268. */
  114269. /**
  114270. * Sets the transparency mode of the material.
  114271. *
  114272. * | Value | Type | Description |
  114273. * | ----- | ----------------------------------- | ----------- |
  114274. * | 0 | OPAQUE | |
  114275. * | 1 | ALPHATEST | |
  114276. * | 2 | ALPHABLEND | |
  114277. * | 3 | ALPHATESTANDBLEND | |
  114278. *
  114279. */
  114280. transparencyMode: Nullable<number>;
  114281. /**
  114282. * Returns true if alpha blending should be disabled.
  114283. */
  114284. private readonly _disableAlphaBlending;
  114285. /**
  114286. * Specifies whether or not this material should be rendered in alpha blend mode.
  114287. */
  114288. needAlphaBlending(): boolean;
  114289. /**
  114290. * Specifies if the mesh will require alpha blending.
  114291. * @param mesh - BJS mesh.
  114292. */
  114293. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  114294. /**
  114295. * Specifies whether or not this material should be rendered in alpha test mode.
  114296. */
  114297. needAlphaTesting(): boolean;
  114298. /**
  114299. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  114300. */
  114301. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  114302. /**
  114303. * Gets the texture used for the alpha test.
  114304. */
  114305. getAlphaTestTexture(): Nullable<BaseTexture>;
  114306. /**
  114307. * Specifies that the submesh is ready to be used.
  114308. * @param mesh - BJS mesh.
  114309. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  114310. * @param useInstances - Specifies that instances should be used.
  114311. * @returns - boolean indicating that the submesh is ready or not.
  114312. */
  114313. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114314. /**
  114315. * Specifies if the material uses metallic roughness workflow.
  114316. * @returns boolean specifiying if the material uses metallic roughness workflow.
  114317. */
  114318. isMetallicWorkflow(): boolean;
  114319. private _prepareEffect;
  114320. private _prepareDefines;
  114321. /**
  114322. * Force shader compilation
  114323. */
  114324. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  114325. clipPlane: boolean;
  114326. }>): void;
  114327. /**
  114328. * Initializes the uniform buffer layout for the shader.
  114329. */
  114330. buildUniformLayout(): void;
  114331. /**
  114332. * Unbinds the material from the mesh
  114333. */
  114334. unbind(): void;
  114335. /**
  114336. * Binds the submesh data.
  114337. * @param world - The world matrix.
  114338. * @param mesh - The BJS mesh.
  114339. * @param subMesh - A submesh of the BJS mesh.
  114340. */
  114341. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114342. /**
  114343. * Returns the animatable textures.
  114344. * @returns - Array of animatable textures.
  114345. */
  114346. getAnimatables(): IAnimatable[];
  114347. /**
  114348. * Returns the texture used for reflections.
  114349. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  114350. */
  114351. private _getReflectionTexture;
  114352. /**
  114353. * Returns an array of the actively used textures.
  114354. * @returns - Array of BaseTextures
  114355. */
  114356. getActiveTextures(): BaseTexture[];
  114357. /**
  114358. * Checks to see if a texture is used in the material.
  114359. * @param texture - Base texture to use.
  114360. * @returns - Boolean specifying if a texture is used in the material.
  114361. */
  114362. hasTexture(texture: BaseTexture): boolean;
  114363. /**
  114364. * Disposes the resources of the material.
  114365. * @param forceDisposeEffect - Forces the disposal of effects.
  114366. * @param forceDisposeTextures - Forces the disposal of all textures.
  114367. */
  114368. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114369. }
  114370. }
  114371. declare module BABYLON {
  114372. /**
  114373. * The Physically based material of BJS.
  114374. *
  114375. * This offers the main features of a standard PBR material.
  114376. * For more information, please refer to the documentation :
  114377. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114378. */
  114379. export class PBRMaterial extends PBRBaseMaterial {
  114380. /**
  114381. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114382. */
  114383. static readonly PBRMATERIAL_OPAQUE: number;
  114384. /**
  114385. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114386. */
  114387. static readonly PBRMATERIAL_ALPHATEST: number;
  114388. /**
  114389. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114390. */
  114391. static readonly PBRMATERIAL_ALPHABLEND: number;
  114392. /**
  114393. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114394. * They are also discarded below the alpha cutoff threshold to improve performances.
  114395. */
  114396. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114397. /**
  114398. * Defines the default value of how much AO map is occluding the analytical lights
  114399. * (point spot...).
  114400. */
  114401. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114402. /**
  114403. * Intensity of the direct lights e.g. the four lights available in your scene.
  114404. * This impacts both the direct diffuse and specular highlights.
  114405. */
  114406. directIntensity: number;
  114407. /**
  114408. * Intensity of the emissive part of the material.
  114409. * This helps controlling the emissive effect without modifying the emissive color.
  114410. */
  114411. emissiveIntensity: number;
  114412. /**
  114413. * Intensity of the environment e.g. how much the environment will light the object
  114414. * either through harmonics for rough material or through the refelction for shiny ones.
  114415. */
  114416. environmentIntensity: number;
  114417. /**
  114418. * This is a special control allowing the reduction of the specular highlights coming from the
  114419. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114420. */
  114421. specularIntensity: number;
  114422. /**
  114423. * Debug Control allowing disabling the bump map on this material.
  114424. */
  114425. disableBumpMap: boolean;
  114426. /**
  114427. * AKA Diffuse Texture in standard nomenclature.
  114428. */
  114429. albedoTexture: BaseTexture;
  114430. /**
  114431. * AKA Occlusion Texture in other nomenclature.
  114432. */
  114433. ambientTexture: BaseTexture;
  114434. /**
  114435. * AKA Occlusion Texture Intensity in other nomenclature.
  114436. */
  114437. ambientTextureStrength: number;
  114438. /**
  114439. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114440. * 1 means it completely occludes it
  114441. * 0 mean it has no impact
  114442. */
  114443. ambientTextureImpactOnAnalyticalLights: number;
  114444. /**
  114445. * Stores the alpha values in a texture.
  114446. */
  114447. opacityTexture: BaseTexture;
  114448. /**
  114449. * Stores the reflection values in a texture.
  114450. */
  114451. reflectionTexture: Nullable<BaseTexture>;
  114452. /**
  114453. * Stores the emissive values in a texture.
  114454. */
  114455. emissiveTexture: BaseTexture;
  114456. /**
  114457. * AKA Specular texture in other nomenclature.
  114458. */
  114459. reflectivityTexture: BaseTexture;
  114460. /**
  114461. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114462. */
  114463. metallicTexture: BaseTexture;
  114464. /**
  114465. * Specifies the metallic scalar of the metallic/roughness workflow.
  114466. * Can also be used to scale the metalness values of the metallic texture.
  114467. */
  114468. metallic: Nullable<number>;
  114469. /**
  114470. * Specifies the roughness scalar of the metallic/roughness workflow.
  114471. * Can also be used to scale the roughness values of the metallic texture.
  114472. */
  114473. roughness: Nullable<number>;
  114474. /**
  114475. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114476. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114477. */
  114478. microSurfaceTexture: BaseTexture;
  114479. /**
  114480. * Stores surface normal data used to displace a mesh in a texture.
  114481. */
  114482. bumpTexture: BaseTexture;
  114483. /**
  114484. * Stores the pre-calculated light information of a mesh in a texture.
  114485. */
  114486. lightmapTexture: BaseTexture;
  114487. /**
  114488. * Stores the refracted light information in a texture.
  114489. */
  114490. refractionTexture: Nullable<BaseTexture>;
  114491. /**
  114492. * The color of a material in ambient lighting.
  114493. */
  114494. ambientColor: Color3;
  114495. /**
  114496. * AKA Diffuse Color in other nomenclature.
  114497. */
  114498. albedoColor: Color3;
  114499. /**
  114500. * AKA Specular Color in other nomenclature.
  114501. */
  114502. reflectivityColor: Color3;
  114503. /**
  114504. * The color reflected from the material.
  114505. */
  114506. reflectionColor: Color3;
  114507. /**
  114508. * The color emitted from the material.
  114509. */
  114510. emissiveColor: Color3;
  114511. /**
  114512. * AKA Glossiness in other nomenclature.
  114513. */
  114514. microSurface: number;
  114515. /**
  114516. * source material index of refraction (IOR)' / 'destination material IOR.
  114517. */
  114518. indexOfRefraction: number;
  114519. /**
  114520. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  114521. */
  114522. invertRefractionY: boolean;
  114523. /**
  114524. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  114525. * Materials half opaque for instance using refraction could benefit from this control.
  114526. */
  114527. linkRefractionWithTransparency: boolean;
  114528. /**
  114529. * If true, the light map contains occlusion information instead of lighting info.
  114530. */
  114531. useLightmapAsShadowmap: boolean;
  114532. /**
  114533. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114534. */
  114535. useAlphaFromAlbedoTexture: boolean;
  114536. /**
  114537. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114538. */
  114539. forceAlphaTest: boolean;
  114540. /**
  114541. * Defines the alpha limits in alpha test mode.
  114542. */
  114543. alphaCutOff: number;
  114544. /**
  114545. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  114546. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114547. */
  114548. useSpecularOverAlpha: boolean;
  114549. /**
  114550. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114551. */
  114552. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114553. /**
  114554. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  114555. */
  114556. useRoughnessFromMetallicTextureAlpha: boolean;
  114557. /**
  114558. * Specifies if the metallic texture contains the roughness information in its green channel.
  114559. */
  114560. useRoughnessFromMetallicTextureGreen: boolean;
  114561. /**
  114562. * Specifies if the metallic texture contains the metallness information in its blue channel.
  114563. */
  114564. useMetallnessFromMetallicTextureBlue: boolean;
  114565. /**
  114566. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  114567. */
  114568. useAmbientOcclusionFromMetallicTextureRed: boolean;
  114569. /**
  114570. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  114571. */
  114572. useAmbientInGrayScale: boolean;
  114573. /**
  114574. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  114575. * The material will try to infer what glossiness each pixel should be.
  114576. */
  114577. useAutoMicroSurfaceFromReflectivityMap: boolean;
  114578. /**
  114579. * BJS is using an harcoded light falloff based on a manually sets up range.
  114580. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  114581. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  114582. */
  114583. /**
  114584. * BJS is using an harcoded light falloff based on a manually sets up range.
  114585. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  114586. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  114587. */
  114588. usePhysicalLightFalloff: boolean;
  114589. /**
  114590. * In order to support the falloff compatibility with gltf, a special mode has been added
  114591. * to reproduce the gltf light falloff.
  114592. */
  114593. /**
  114594. * In order to support the falloff compatibility with gltf, a special mode has been added
  114595. * to reproduce the gltf light falloff.
  114596. */
  114597. useGLTFLightFalloff: boolean;
  114598. /**
  114599. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  114600. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  114601. */
  114602. useRadianceOverAlpha: boolean;
  114603. /**
  114604. * Allows using an object space normal map (instead of tangent space).
  114605. */
  114606. useObjectSpaceNormalMap: boolean;
  114607. /**
  114608. * Allows using the bump map in parallax mode.
  114609. */
  114610. useParallax: boolean;
  114611. /**
  114612. * Allows using the bump map in parallax occlusion mode.
  114613. */
  114614. useParallaxOcclusion: boolean;
  114615. /**
  114616. * Controls the scale bias of the parallax mode.
  114617. */
  114618. parallaxScaleBias: number;
  114619. /**
  114620. * If sets to true, disables all the lights affecting the material.
  114621. */
  114622. disableLighting: boolean;
  114623. /**
  114624. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  114625. */
  114626. forceIrradianceInFragment: boolean;
  114627. /**
  114628. * Number of Simultaneous lights allowed on the material.
  114629. */
  114630. maxSimultaneousLights: number;
  114631. /**
  114632. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  114633. */
  114634. invertNormalMapX: boolean;
  114635. /**
  114636. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  114637. */
  114638. invertNormalMapY: boolean;
  114639. /**
  114640. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114641. */
  114642. twoSidedLighting: boolean;
  114643. /**
  114644. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114645. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  114646. */
  114647. useAlphaFresnel: boolean;
  114648. /**
  114649. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114650. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  114651. */
  114652. useLinearAlphaFresnel: boolean;
  114653. /**
  114654. * Let user defines the brdf lookup texture used for IBL.
  114655. * A default 8bit version is embedded but you could point at :
  114656. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  114657. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  114658. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  114659. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  114660. */
  114661. environmentBRDFTexture: Nullable<BaseTexture>;
  114662. /**
  114663. * Force normal to face away from face.
  114664. */
  114665. forceNormalForward: boolean;
  114666. /**
  114667. * Enables specular anti aliasing in the PBR shader.
  114668. * It will both interacts on the Geometry for analytical and IBL lighting.
  114669. * It also prefilter the roughness map based on the bump values.
  114670. */
  114671. enableSpecularAntiAliasing: boolean;
  114672. /**
  114673. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  114674. * makes the reflect vector face the model (under horizon).
  114675. */
  114676. useHorizonOcclusion: boolean;
  114677. /**
  114678. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  114679. * too much the area relying on ambient texture to define their ambient occlusion.
  114680. */
  114681. useRadianceOcclusion: boolean;
  114682. /**
  114683. * If set to true, no lighting calculations will be applied.
  114684. */
  114685. unlit: boolean;
  114686. /**
  114687. * Gets the image processing configuration used either in this material.
  114688. */
  114689. /**
  114690. * Sets the Default image processing configuration used either in the this material.
  114691. *
  114692. * If sets to null, the scene one is in use.
  114693. */
  114694. imageProcessingConfiguration: ImageProcessingConfiguration;
  114695. /**
  114696. * Gets wether the color curves effect is enabled.
  114697. */
  114698. /**
  114699. * Sets wether the color curves effect is enabled.
  114700. */
  114701. cameraColorCurvesEnabled: boolean;
  114702. /**
  114703. * Gets wether the color grading effect is enabled.
  114704. */
  114705. /**
  114706. * Gets wether the color grading effect is enabled.
  114707. */
  114708. cameraColorGradingEnabled: boolean;
  114709. /**
  114710. * Gets wether tonemapping is enabled or not.
  114711. */
  114712. /**
  114713. * Sets wether tonemapping is enabled or not
  114714. */
  114715. cameraToneMappingEnabled: boolean;
  114716. /**
  114717. * The camera exposure used on this material.
  114718. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114719. * This corresponds to a photographic exposure.
  114720. */
  114721. /**
  114722. * The camera exposure used on this material.
  114723. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114724. * This corresponds to a photographic exposure.
  114725. */
  114726. cameraExposure: number;
  114727. /**
  114728. * Gets The camera contrast used on this material.
  114729. */
  114730. /**
  114731. * Sets The camera contrast used on this material.
  114732. */
  114733. cameraContrast: number;
  114734. /**
  114735. * Gets the Color Grading 2D Lookup Texture.
  114736. */
  114737. /**
  114738. * Sets the Color Grading 2D Lookup Texture.
  114739. */
  114740. cameraColorGradingTexture: Nullable<BaseTexture>;
  114741. /**
  114742. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114743. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114744. * 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;
  114745. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114746. */
  114747. /**
  114748. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114749. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114750. * 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;
  114751. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114752. */
  114753. cameraColorCurves: Nullable<ColorCurves>;
  114754. /**
  114755. * Instantiates a new PBRMaterial instance.
  114756. *
  114757. * @param name The material name
  114758. * @param scene The scene the material will be use in.
  114759. */
  114760. constructor(name: string, scene: Scene);
  114761. /**
  114762. * Returns the name of this material class.
  114763. */
  114764. getClassName(): string;
  114765. /**
  114766. * Makes a duplicate of the current material.
  114767. * @param name - name to use for the new material.
  114768. */
  114769. clone(name: string): PBRMaterial;
  114770. /**
  114771. * Serializes this PBR Material.
  114772. * @returns - An object with the serialized material.
  114773. */
  114774. serialize(): any;
  114775. /**
  114776. * Parses a PBR Material from a serialized object.
  114777. * @param source - Serialized object.
  114778. * @param scene - BJS scene instance.
  114779. * @param rootUrl - url for the scene object
  114780. * @returns - PBRMaterial
  114781. */
  114782. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  114783. }
  114784. }
  114785. declare module BABYLON {
  114786. /**
  114787. * Direct draw surface info
  114788. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  114789. */
  114790. export interface DDSInfo {
  114791. /**
  114792. * Width of the texture
  114793. */
  114794. width: number;
  114795. /**
  114796. * Width of the texture
  114797. */
  114798. height: number;
  114799. /**
  114800. * Number of Mipmaps for the texture
  114801. * @see https://en.wikipedia.org/wiki/Mipmap
  114802. */
  114803. mipmapCount: number;
  114804. /**
  114805. * If the textures format is a known fourCC format
  114806. * @see https://www.fourcc.org/
  114807. */
  114808. isFourCC: boolean;
  114809. /**
  114810. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  114811. */
  114812. isRGB: boolean;
  114813. /**
  114814. * If the texture is a lumincance format
  114815. */
  114816. isLuminance: boolean;
  114817. /**
  114818. * If this is a cube texture
  114819. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  114820. */
  114821. isCube: boolean;
  114822. /**
  114823. * If the texture is a compressed format eg. FOURCC_DXT1
  114824. */
  114825. isCompressed: boolean;
  114826. /**
  114827. * The dxgiFormat of the texture
  114828. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  114829. */
  114830. dxgiFormat: number;
  114831. /**
  114832. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  114833. */
  114834. textureType: number;
  114835. /**
  114836. * Sphericle polynomial created for the dds texture
  114837. */
  114838. sphericalPolynomial?: SphericalPolynomial;
  114839. }
  114840. /**
  114841. * Class used to provide DDS decompression tools
  114842. */
  114843. export class DDSTools {
  114844. /**
  114845. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  114846. */
  114847. static StoreLODInAlphaChannel: boolean;
  114848. /**
  114849. * Gets DDS information from an array buffer
  114850. * @param arrayBuffer defines the array buffer to read data from
  114851. * @returns the DDS information
  114852. */
  114853. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  114854. private static _FloatView;
  114855. private static _Int32View;
  114856. private static _ToHalfFloat;
  114857. private static _FromHalfFloat;
  114858. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  114859. private static _GetHalfFloatRGBAArrayBuffer;
  114860. private static _GetFloatRGBAArrayBuffer;
  114861. private static _GetFloatAsUIntRGBAArrayBuffer;
  114862. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  114863. private static _GetRGBAArrayBuffer;
  114864. private static _ExtractLongWordOrder;
  114865. private static _GetRGBArrayBuffer;
  114866. private static _GetLuminanceArrayBuffer;
  114867. /**
  114868. * Uploads DDS Levels to a Babylon Texture
  114869. * @hidden
  114870. */
  114871. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  114872. }
  114873. interface ThinEngine {
  114874. /**
  114875. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  114876. * @param rootUrl defines the url where the file to load is located
  114877. * @param scene defines the current scene
  114878. * @param lodScale defines scale to apply to the mip map selection
  114879. * @param lodOffset defines offset to apply to the mip map selection
  114880. * @param onLoad defines an optional callback raised when the texture is loaded
  114881. * @param onError defines an optional callback raised if there is an issue to load the texture
  114882. * @param format defines the format of the data
  114883. * @param forcedExtension defines the extension to use to pick the right loader
  114884. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  114885. * @returns the cube texture as an InternalTexture
  114886. */
  114887. 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;
  114888. }
  114889. }
  114890. declare module BABYLON {
  114891. /**
  114892. * Implementation of the DDS Texture Loader.
  114893. * @hidden
  114894. */
  114895. export class _DDSTextureLoader implements IInternalTextureLoader {
  114896. /**
  114897. * Defines wether the loader supports cascade loading the different faces.
  114898. */
  114899. readonly supportCascades: boolean;
  114900. /**
  114901. * This returns if the loader support the current file information.
  114902. * @param extension defines the file extension of the file being loaded
  114903. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114904. * @param fallback defines the fallback internal texture if any
  114905. * @param isBase64 defines whether the texture is encoded as a base64
  114906. * @param isBuffer defines whether the texture data are stored as a buffer
  114907. * @returns true if the loader can load the specified file
  114908. */
  114909. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114910. /**
  114911. * Transform the url before loading if required.
  114912. * @param rootUrl the url of the texture
  114913. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114914. * @returns the transformed texture
  114915. */
  114916. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114917. /**
  114918. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114919. * @param rootUrl the url of the texture
  114920. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114921. * @returns the fallback texture
  114922. */
  114923. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114924. /**
  114925. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114926. * @param data contains the texture data
  114927. * @param texture defines the BabylonJS internal texture
  114928. * @param createPolynomials will be true if polynomials have been requested
  114929. * @param onLoad defines the callback to trigger once the texture is ready
  114930. * @param onError defines the callback to trigger in case of error
  114931. */
  114932. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114933. /**
  114934. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114935. * @param data contains the texture data
  114936. * @param texture defines the BabylonJS internal texture
  114937. * @param callback defines the method to call once ready to upload
  114938. */
  114939. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114940. }
  114941. }
  114942. declare module BABYLON {
  114943. /**
  114944. * Implementation of the ENV Texture Loader.
  114945. * @hidden
  114946. */
  114947. export class _ENVTextureLoader implements IInternalTextureLoader {
  114948. /**
  114949. * Defines wether the loader supports cascade loading the different faces.
  114950. */
  114951. readonly supportCascades: boolean;
  114952. /**
  114953. * This returns if the loader support the current file information.
  114954. * @param extension defines the file extension of the file being loaded
  114955. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114956. * @param fallback defines the fallback internal texture if any
  114957. * @param isBase64 defines whether the texture is encoded as a base64
  114958. * @param isBuffer defines whether the texture data are stored as a buffer
  114959. * @returns true if the loader can load the specified file
  114960. */
  114961. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114962. /**
  114963. * Transform the url before loading if required.
  114964. * @param rootUrl the url of the texture
  114965. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114966. * @returns the transformed texture
  114967. */
  114968. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114969. /**
  114970. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114971. * @param rootUrl the url of the texture
  114972. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114973. * @returns the fallback texture
  114974. */
  114975. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114976. /**
  114977. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114978. * @param data contains the texture data
  114979. * @param texture defines the BabylonJS internal texture
  114980. * @param createPolynomials will be true if polynomials have been requested
  114981. * @param onLoad defines the callback to trigger once the texture is ready
  114982. * @param onError defines the callback to trigger in case of error
  114983. */
  114984. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114985. /**
  114986. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114987. * @param data contains the texture data
  114988. * @param texture defines the BabylonJS internal texture
  114989. * @param callback defines the method to call once ready to upload
  114990. */
  114991. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114992. }
  114993. }
  114994. declare module BABYLON {
  114995. /**
  114996. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  114997. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  114998. */
  114999. export class KhronosTextureContainer {
  115000. /** contents of the KTX container file */
  115001. arrayBuffer: any;
  115002. private static HEADER_LEN;
  115003. private static COMPRESSED_2D;
  115004. private static COMPRESSED_3D;
  115005. private static TEX_2D;
  115006. private static TEX_3D;
  115007. /**
  115008. * Gets the openGL type
  115009. */
  115010. glType: number;
  115011. /**
  115012. * Gets the openGL type size
  115013. */
  115014. glTypeSize: number;
  115015. /**
  115016. * Gets the openGL format
  115017. */
  115018. glFormat: number;
  115019. /**
  115020. * Gets the openGL internal format
  115021. */
  115022. glInternalFormat: number;
  115023. /**
  115024. * Gets the base internal format
  115025. */
  115026. glBaseInternalFormat: number;
  115027. /**
  115028. * Gets image width in pixel
  115029. */
  115030. pixelWidth: number;
  115031. /**
  115032. * Gets image height in pixel
  115033. */
  115034. pixelHeight: number;
  115035. /**
  115036. * Gets image depth in pixels
  115037. */
  115038. pixelDepth: number;
  115039. /**
  115040. * Gets the number of array elements
  115041. */
  115042. numberOfArrayElements: number;
  115043. /**
  115044. * Gets the number of faces
  115045. */
  115046. numberOfFaces: number;
  115047. /**
  115048. * Gets the number of mipmap levels
  115049. */
  115050. numberOfMipmapLevels: number;
  115051. /**
  115052. * Gets the bytes of key value data
  115053. */
  115054. bytesOfKeyValueData: number;
  115055. /**
  115056. * Gets the load type
  115057. */
  115058. loadType: number;
  115059. /**
  115060. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  115061. */
  115062. isInvalid: boolean;
  115063. /**
  115064. * Creates a new KhronosTextureContainer
  115065. * @param arrayBuffer contents of the KTX container file
  115066. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  115067. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  115068. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  115069. */
  115070. constructor(
  115071. /** contents of the KTX container file */
  115072. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  115073. /**
  115074. * Uploads KTX content to a Babylon Texture.
  115075. * It is assumed that the texture has already been created & is currently bound
  115076. * @hidden
  115077. */
  115078. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  115079. private _upload2DCompressedLevels;
  115080. }
  115081. }
  115082. declare module BABYLON {
  115083. /**
  115084. * Implementation of the KTX Texture Loader.
  115085. * @hidden
  115086. */
  115087. export class _KTXTextureLoader implements IInternalTextureLoader {
  115088. /**
  115089. * Defines wether the loader supports cascade loading the different faces.
  115090. */
  115091. readonly supportCascades: boolean;
  115092. /**
  115093. * This returns if the loader support the current file information.
  115094. * @param extension defines the file extension of the file being loaded
  115095. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115096. * @param fallback defines the fallback internal texture if any
  115097. * @param isBase64 defines whether the texture is encoded as a base64
  115098. * @param isBuffer defines whether the texture data are stored as a buffer
  115099. * @returns true if the loader can load the specified file
  115100. */
  115101. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115102. /**
  115103. * Transform the url before loading if required.
  115104. * @param rootUrl the url of the texture
  115105. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115106. * @returns the transformed texture
  115107. */
  115108. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115109. /**
  115110. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115111. * @param rootUrl the url of the texture
  115112. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115113. * @returns the fallback texture
  115114. */
  115115. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115116. /**
  115117. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115118. * @param data contains the texture data
  115119. * @param texture defines the BabylonJS internal texture
  115120. * @param createPolynomials will be true if polynomials have been requested
  115121. * @param onLoad defines the callback to trigger once the texture is ready
  115122. * @param onError defines the callback to trigger in case of error
  115123. */
  115124. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115125. /**
  115126. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115127. * @param data contains the texture data
  115128. * @param texture defines the BabylonJS internal texture
  115129. * @param callback defines the method to call once ready to upload
  115130. */
  115131. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  115132. }
  115133. }
  115134. declare module BABYLON {
  115135. /**
  115136. * Options for the default xr helper
  115137. */
  115138. export class WebXRDefaultExperienceOptions {
  115139. /**
  115140. * Floor meshes that should be used for teleporting
  115141. */
  115142. floorMeshes: Array<AbstractMesh>;
  115143. }
  115144. /**
  115145. * Default experience which provides a similar setup to the previous webVRExperience
  115146. */
  115147. export class WebXRDefaultExperience {
  115148. /**
  115149. * Base experience
  115150. */
  115151. baseExperience: WebXRExperienceHelper;
  115152. /**
  115153. * Input experience extension
  115154. */
  115155. input: WebXRInput;
  115156. /**
  115157. * Loads the controller models
  115158. */
  115159. controllerModelLoader: WebXRControllerModelLoader;
  115160. /**
  115161. * Enables laser pointer and selection
  115162. */
  115163. pointerSelection: WebXRControllerPointerSelection;
  115164. /**
  115165. * Enables teleportation
  115166. */
  115167. teleportation: WebXRControllerTeleportation;
  115168. /**
  115169. * Enables ui for enetering/exiting xr
  115170. */
  115171. enterExitUI: WebXREnterExitUI;
  115172. /**
  115173. * Default output canvas xr should render to
  115174. */
  115175. outputCanvas: WebXRManagedOutputCanvas;
  115176. /**
  115177. * Creates the default xr experience
  115178. * @param scene scene
  115179. * @param options options for basic configuration
  115180. * @returns resulting WebXRDefaultExperience
  115181. */
  115182. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115183. private constructor();
  115184. /**
  115185. * DIsposes of the experience helper
  115186. */
  115187. dispose(): void;
  115188. }
  115189. }
  115190. declare module BABYLON {
  115191. /** @hidden */
  115192. export var _forceSceneHelpersToBundle: boolean;
  115193. interface Scene {
  115194. /**
  115195. * Creates a default light for the scene.
  115196. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  115197. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  115198. */
  115199. createDefaultLight(replace?: boolean): void;
  115200. /**
  115201. * Creates a default camera for the scene.
  115202. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  115203. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115204. * @param replace has default false, when true replaces the active camera in the scene
  115205. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  115206. */
  115207. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115208. /**
  115209. * Creates a default camera and a default light.
  115210. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  115211. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115212. * @param replace has the default false, when true replaces the active camera/light in the scene
  115213. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  115214. */
  115215. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115216. /**
  115217. * Creates a new sky box
  115218. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  115219. * @param environmentTexture defines the texture to use as environment texture
  115220. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  115221. * @param scale defines the overall scale of the skybox
  115222. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  115223. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  115224. * @returns a new mesh holding the sky box
  115225. */
  115226. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  115227. /**
  115228. * Creates a new environment
  115229. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  115230. * @param options defines the options you can use to configure the environment
  115231. * @returns the new EnvironmentHelper
  115232. */
  115233. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  115234. /**
  115235. * Creates a new VREXperienceHelper
  115236. * @see http://doc.babylonjs.com/how_to/webvr_helper
  115237. * @param webVROptions defines the options used to create the new VREXperienceHelper
  115238. * @returns a new VREXperienceHelper
  115239. */
  115240. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  115241. /**
  115242. * Creates a new WebXRDefaultExperience
  115243. * @see http://doc.babylonjs.com/how_to/webxr
  115244. * @param options experience options
  115245. * @returns a promise for a new WebXRDefaultExperience
  115246. */
  115247. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115248. }
  115249. }
  115250. declare module BABYLON {
  115251. /**
  115252. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  115253. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  115254. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  115255. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  115256. */
  115257. export class VideoDome extends TransformNode {
  115258. /**
  115259. * Define the video source as a Monoscopic panoramic 360 video.
  115260. */
  115261. static readonly MODE_MONOSCOPIC: number;
  115262. /**
  115263. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115264. */
  115265. static readonly MODE_TOPBOTTOM: number;
  115266. /**
  115267. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115268. */
  115269. static readonly MODE_SIDEBYSIDE: number;
  115270. private _halfDome;
  115271. private _useDirectMapping;
  115272. /**
  115273. * The video texture being displayed on the sphere
  115274. */
  115275. protected _videoTexture: VideoTexture;
  115276. /**
  115277. * Gets the video texture being displayed on the sphere
  115278. */
  115279. readonly videoTexture: VideoTexture;
  115280. /**
  115281. * The skybox material
  115282. */
  115283. protected _material: BackgroundMaterial;
  115284. /**
  115285. * The surface used for the skybox
  115286. */
  115287. protected _mesh: Mesh;
  115288. /**
  115289. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  115290. */
  115291. private _halfDomeMask;
  115292. /**
  115293. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115294. * Also see the options.resolution property.
  115295. */
  115296. fovMultiplier: number;
  115297. private _videoMode;
  115298. /**
  115299. * Gets or set the current video mode for the video. It can be:
  115300. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  115301. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115302. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115303. */
  115304. videoMode: number;
  115305. /**
  115306. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  115307. *
  115308. */
  115309. /**
  115310. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  115311. */
  115312. halfDome: boolean;
  115313. /**
  115314. * Oberserver used in Stereoscopic VR Mode.
  115315. */
  115316. private _onBeforeCameraRenderObserver;
  115317. /**
  115318. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  115319. * @param name Element's name, child elements will append suffixes for their own names.
  115320. * @param urlsOrVideo defines the url(s) or the video element to use
  115321. * @param options An object containing optional or exposed sub element properties
  115322. */
  115323. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  115324. resolution?: number;
  115325. clickToPlay?: boolean;
  115326. autoPlay?: boolean;
  115327. loop?: boolean;
  115328. size?: number;
  115329. poster?: string;
  115330. faceForward?: boolean;
  115331. useDirectMapping?: boolean;
  115332. halfDomeMode?: boolean;
  115333. }, scene: Scene);
  115334. private _changeVideoMode;
  115335. /**
  115336. * Releases resources associated with this node.
  115337. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115338. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115339. */
  115340. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115341. }
  115342. }
  115343. declare module BABYLON {
  115344. /**
  115345. * This class can be used to get instrumentation data from a Babylon engine
  115346. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115347. */
  115348. export class EngineInstrumentation implements IDisposable {
  115349. /**
  115350. * Define the instrumented engine.
  115351. */
  115352. engine: Engine;
  115353. private _captureGPUFrameTime;
  115354. private _gpuFrameTimeToken;
  115355. private _gpuFrameTime;
  115356. private _captureShaderCompilationTime;
  115357. private _shaderCompilationTime;
  115358. private _onBeginFrameObserver;
  115359. private _onEndFrameObserver;
  115360. private _onBeforeShaderCompilationObserver;
  115361. private _onAfterShaderCompilationObserver;
  115362. /**
  115363. * Gets the perf counter used for GPU frame time
  115364. */
  115365. readonly gpuFrameTimeCounter: PerfCounter;
  115366. /**
  115367. * Gets the GPU frame time capture status
  115368. */
  115369. /**
  115370. * Enable or disable the GPU frame time capture
  115371. */
  115372. captureGPUFrameTime: boolean;
  115373. /**
  115374. * Gets the perf counter used for shader compilation time
  115375. */
  115376. readonly shaderCompilationTimeCounter: PerfCounter;
  115377. /**
  115378. * Gets the shader compilation time capture status
  115379. */
  115380. /**
  115381. * Enable or disable the shader compilation time capture
  115382. */
  115383. captureShaderCompilationTime: boolean;
  115384. /**
  115385. * Instantiates a new engine instrumentation.
  115386. * This class can be used to get instrumentation data from a Babylon engine
  115387. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115388. * @param engine Defines the engine to instrument
  115389. */
  115390. constructor(
  115391. /**
  115392. * Define the instrumented engine.
  115393. */
  115394. engine: Engine);
  115395. /**
  115396. * Dispose and release associated resources.
  115397. */
  115398. dispose(): void;
  115399. }
  115400. }
  115401. declare module BABYLON {
  115402. /**
  115403. * This class can be used to get instrumentation data from a Babylon engine
  115404. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  115405. */
  115406. export class SceneInstrumentation implements IDisposable {
  115407. /**
  115408. * Defines the scene to instrument
  115409. */
  115410. scene: Scene;
  115411. private _captureActiveMeshesEvaluationTime;
  115412. private _activeMeshesEvaluationTime;
  115413. private _captureRenderTargetsRenderTime;
  115414. private _renderTargetsRenderTime;
  115415. private _captureFrameTime;
  115416. private _frameTime;
  115417. private _captureRenderTime;
  115418. private _renderTime;
  115419. private _captureInterFrameTime;
  115420. private _interFrameTime;
  115421. private _captureParticlesRenderTime;
  115422. private _particlesRenderTime;
  115423. private _captureSpritesRenderTime;
  115424. private _spritesRenderTime;
  115425. private _capturePhysicsTime;
  115426. private _physicsTime;
  115427. private _captureAnimationsTime;
  115428. private _animationsTime;
  115429. private _captureCameraRenderTime;
  115430. private _cameraRenderTime;
  115431. private _onBeforeActiveMeshesEvaluationObserver;
  115432. private _onAfterActiveMeshesEvaluationObserver;
  115433. private _onBeforeRenderTargetsRenderObserver;
  115434. private _onAfterRenderTargetsRenderObserver;
  115435. private _onAfterRenderObserver;
  115436. private _onBeforeDrawPhaseObserver;
  115437. private _onAfterDrawPhaseObserver;
  115438. private _onBeforeAnimationsObserver;
  115439. private _onBeforeParticlesRenderingObserver;
  115440. private _onAfterParticlesRenderingObserver;
  115441. private _onBeforeSpritesRenderingObserver;
  115442. private _onAfterSpritesRenderingObserver;
  115443. private _onBeforePhysicsObserver;
  115444. private _onAfterPhysicsObserver;
  115445. private _onAfterAnimationsObserver;
  115446. private _onBeforeCameraRenderObserver;
  115447. private _onAfterCameraRenderObserver;
  115448. /**
  115449. * Gets the perf counter used for active meshes evaluation time
  115450. */
  115451. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  115452. /**
  115453. * Gets the active meshes evaluation time capture status
  115454. */
  115455. /**
  115456. * Enable or disable the active meshes evaluation time capture
  115457. */
  115458. captureActiveMeshesEvaluationTime: boolean;
  115459. /**
  115460. * Gets the perf counter used for render targets render time
  115461. */
  115462. readonly renderTargetsRenderTimeCounter: PerfCounter;
  115463. /**
  115464. * Gets the render targets render time capture status
  115465. */
  115466. /**
  115467. * Enable or disable the render targets render time capture
  115468. */
  115469. captureRenderTargetsRenderTime: boolean;
  115470. /**
  115471. * Gets the perf counter used for particles render time
  115472. */
  115473. readonly particlesRenderTimeCounter: PerfCounter;
  115474. /**
  115475. * Gets the particles render time capture status
  115476. */
  115477. /**
  115478. * Enable or disable the particles render time capture
  115479. */
  115480. captureParticlesRenderTime: boolean;
  115481. /**
  115482. * Gets the perf counter used for sprites render time
  115483. */
  115484. readonly spritesRenderTimeCounter: PerfCounter;
  115485. /**
  115486. * Gets the sprites render time capture status
  115487. */
  115488. /**
  115489. * Enable or disable the sprites render time capture
  115490. */
  115491. captureSpritesRenderTime: boolean;
  115492. /**
  115493. * Gets the perf counter used for physics time
  115494. */
  115495. readonly physicsTimeCounter: PerfCounter;
  115496. /**
  115497. * Gets the physics time capture status
  115498. */
  115499. /**
  115500. * Enable or disable the physics time capture
  115501. */
  115502. capturePhysicsTime: boolean;
  115503. /**
  115504. * Gets the perf counter used for animations time
  115505. */
  115506. readonly animationsTimeCounter: PerfCounter;
  115507. /**
  115508. * Gets the animations time capture status
  115509. */
  115510. /**
  115511. * Enable or disable the animations time capture
  115512. */
  115513. captureAnimationsTime: boolean;
  115514. /**
  115515. * Gets the perf counter used for frame time capture
  115516. */
  115517. readonly frameTimeCounter: PerfCounter;
  115518. /**
  115519. * Gets the frame time capture status
  115520. */
  115521. /**
  115522. * Enable or disable the frame time capture
  115523. */
  115524. captureFrameTime: boolean;
  115525. /**
  115526. * Gets the perf counter used for inter-frames time capture
  115527. */
  115528. readonly interFrameTimeCounter: PerfCounter;
  115529. /**
  115530. * Gets the inter-frames time capture status
  115531. */
  115532. /**
  115533. * Enable or disable the inter-frames time capture
  115534. */
  115535. captureInterFrameTime: boolean;
  115536. /**
  115537. * Gets the perf counter used for render time capture
  115538. */
  115539. readonly renderTimeCounter: PerfCounter;
  115540. /**
  115541. * Gets the render time capture status
  115542. */
  115543. /**
  115544. * Enable or disable the render time capture
  115545. */
  115546. captureRenderTime: boolean;
  115547. /**
  115548. * Gets the perf counter used for camera render time capture
  115549. */
  115550. readonly cameraRenderTimeCounter: PerfCounter;
  115551. /**
  115552. * Gets the camera render time capture status
  115553. */
  115554. /**
  115555. * Enable or disable the camera render time capture
  115556. */
  115557. captureCameraRenderTime: boolean;
  115558. /**
  115559. * Gets the perf counter used for draw calls
  115560. */
  115561. readonly drawCallsCounter: PerfCounter;
  115562. /**
  115563. * Instantiates a new scene instrumentation.
  115564. * This class can be used to get instrumentation data from a Babylon engine
  115565. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  115566. * @param scene Defines the scene to instrument
  115567. */
  115568. constructor(
  115569. /**
  115570. * Defines the scene to instrument
  115571. */
  115572. scene: Scene);
  115573. /**
  115574. * Dispose and release associated resources.
  115575. */
  115576. dispose(): void;
  115577. }
  115578. }
  115579. declare module BABYLON {
  115580. /** @hidden */
  115581. export var glowMapGenerationPixelShader: {
  115582. name: string;
  115583. shader: string;
  115584. };
  115585. }
  115586. declare module BABYLON {
  115587. /** @hidden */
  115588. export var glowMapGenerationVertexShader: {
  115589. name: string;
  115590. shader: string;
  115591. };
  115592. }
  115593. declare module BABYLON {
  115594. /**
  115595. * Effect layer options. This helps customizing the behaviour
  115596. * of the effect layer.
  115597. */
  115598. export interface IEffectLayerOptions {
  115599. /**
  115600. * Multiplication factor apply to the canvas size to compute the render target size
  115601. * used to generated the objects (the smaller the faster).
  115602. */
  115603. mainTextureRatio: number;
  115604. /**
  115605. * Enforces a fixed size texture to ensure effect stability across devices.
  115606. */
  115607. mainTextureFixedSize?: number;
  115608. /**
  115609. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  115610. */
  115611. alphaBlendingMode: number;
  115612. /**
  115613. * The camera attached to the layer.
  115614. */
  115615. camera: Nullable<Camera>;
  115616. /**
  115617. * The rendering group to draw the layer in.
  115618. */
  115619. renderingGroupId: number;
  115620. }
  115621. /**
  115622. * The effect layer Helps adding post process effect blended with the main pass.
  115623. *
  115624. * This can be for instance use to generate glow or higlight effects on the scene.
  115625. *
  115626. * The effect layer class can not be used directly and is intented to inherited from to be
  115627. * customized per effects.
  115628. */
  115629. export abstract class EffectLayer {
  115630. private _vertexBuffers;
  115631. private _indexBuffer;
  115632. private _cachedDefines;
  115633. private _effectLayerMapGenerationEffect;
  115634. private _effectLayerOptions;
  115635. private _mergeEffect;
  115636. protected _scene: Scene;
  115637. protected _engine: Engine;
  115638. protected _maxSize: number;
  115639. protected _mainTextureDesiredSize: ISize;
  115640. protected _mainTexture: RenderTargetTexture;
  115641. protected _shouldRender: boolean;
  115642. protected _postProcesses: PostProcess[];
  115643. protected _textures: BaseTexture[];
  115644. protected _emissiveTextureAndColor: {
  115645. texture: Nullable<BaseTexture>;
  115646. color: Color4;
  115647. };
  115648. /**
  115649. * The name of the layer
  115650. */
  115651. name: string;
  115652. /**
  115653. * The clear color of the texture used to generate the glow map.
  115654. */
  115655. neutralColor: Color4;
  115656. /**
  115657. * Specifies wether the highlight layer is enabled or not.
  115658. */
  115659. isEnabled: boolean;
  115660. /**
  115661. * Gets the camera attached to the layer.
  115662. */
  115663. readonly camera: Nullable<Camera>;
  115664. /**
  115665. * Gets the rendering group id the layer should render in.
  115666. */
  115667. renderingGroupId: number;
  115668. /**
  115669. * An event triggered when the effect layer has been disposed.
  115670. */
  115671. onDisposeObservable: Observable<EffectLayer>;
  115672. /**
  115673. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  115674. */
  115675. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  115676. /**
  115677. * An event triggered when the generated texture is being merged in the scene.
  115678. */
  115679. onBeforeComposeObservable: Observable<EffectLayer>;
  115680. /**
  115681. * An event triggered when the generated texture has been merged in the scene.
  115682. */
  115683. onAfterComposeObservable: Observable<EffectLayer>;
  115684. /**
  115685. * An event triggered when the efffect layer changes its size.
  115686. */
  115687. onSizeChangedObservable: Observable<EffectLayer>;
  115688. /** @hidden */
  115689. static _SceneComponentInitialization: (scene: Scene) => void;
  115690. /**
  115691. * Instantiates a new effect Layer and references it in the scene.
  115692. * @param name The name of the layer
  115693. * @param scene The scene to use the layer in
  115694. */
  115695. constructor(
  115696. /** The Friendly of the effect in the scene */
  115697. name: string, scene: Scene);
  115698. /**
  115699. * Get the effect name of the layer.
  115700. * @return The effect name
  115701. */
  115702. abstract getEffectName(): string;
  115703. /**
  115704. * Checks for the readiness of the element composing the layer.
  115705. * @param subMesh the mesh to check for
  115706. * @param useInstances specify wether or not to use instances to render the mesh
  115707. * @return true if ready otherwise, false
  115708. */
  115709. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115710. /**
  115711. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115712. * @returns true if the effect requires stencil during the main canvas render pass.
  115713. */
  115714. abstract needStencil(): boolean;
  115715. /**
  115716. * Create the merge effect. This is the shader use to blit the information back
  115717. * to the main canvas at the end of the scene rendering.
  115718. * @returns The effect containing the shader used to merge the effect on the main canvas
  115719. */
  115720. protected abstract _createMergeEffect(): Effect;
  115721. /**
  115722. * Creates the render target textures and post processes used in the effect layer.
  115723. */
  115724. protected abstract _createTextureAndPostProcesses(): void;
  115725. /**
  115726. * Implementation specific of rendering the generating effect on the main canvas.
  115727. * @param effect The effect used to render through
  115728. */
  115729. protected abstract _internalRender(effect: Effect): void;
  115730. /**
  115731. * Sets the required values for both the emissive texture and and the main color.
  115732. */
  115733. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115734. /**
  115735. * Free any resources and references associated to a mesh.
  115736. * Internal use
  115737. * @param mesh The mesh to free.
  115738. */
  115739. abstract _disposeMesh(mesh: Mesh): void;
  115740. /**
  115741. * Serializes this layer (Glow or Highlight for example)
  115742. * @returns a serialized layer object
  115743. */
  115744. abstract serialize?(): any;
  115745. /**
  115746. * Initializes the effect layer with the required options.
  115747. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  115748. */
  115749. protected _init(options: Partial<IEffectLayerOptions>): void;
  115750. /**
  115751. * Generates the index buffer of the full screen quad blending to the main canvas.
  115752. */
  115753. private _generateIndexBuffer;
  115754. /**
  115755. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  115756. */
  115757. private _generateVertexBuffer;
  115758. /**
  115759. * Sets the main texture desired size which is the closest power of two
  115760. * of the engine canvas size.
  115761. */
  115762. private _setMainTextureSize;
  115763. /**
  115764. * Creates the main texture for the effect layer.
  115765. */
  115766. protected _createMainTexture(): void;
  115767. /**
  115768. * Adds specific effects defines.
  115769. * @param defines The defines to add specifics to.
  115770. */
  115771. protected _addCustomEffectDefines(defines: string[]): void;
  115772. /**
  115773. * Checks for the readiness of the element composing the layer.
  115774. * @param subMesh the mesh to check for
  115775. * @param useInstances specify wether or not to use instances to render the mesh
  115776. * @param emissiveTexture the associated emissive texture used to generate the glow
  115777. * @return true if ready otherwise, false
  115778. */
  115779. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  115780. /**
  115781. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  115782. */
  115783. render(): void;
  115784. /**
  115785. * Determine if a given mesh will be used in the current effect.
  115786. * @param mesh mesh to test
  115787. * @returns true if the mesh will be used
  115788. */
  115789. hasMesh(mesh: AbstractMesh): boolean;
  115790. /**
  115791. * Returns true if the layer contains information to display, otherwise false.
  115792. * @returns true if the glow layer should be rendered
  115793. */
  115794. shouldRender(): boolean;
  115795. /**
  115796. * Returns true if the mesh should render, otherwise false.
  115797. * @param mesh The mesh to render
  115798. * @returns true if it should render otherwise false
  115799. */
  115800. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  115801. /**
  115802. * Returns true if the mesh can be rendered, otherwise false.
  115803. * @param mesh The mesh to render
  115804. * @param material The material used on the mesh
  115805. * @returns true if it can be rendered otherwise false
  115806. */
  115807. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  115808. /**
  115809. * Returns true if the mesh should render, otherwise false.
  115810. * @param mesh The mesh to render
  115811. * @returns true if it should render otherwise false
  115812. */
  115813. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  115814. /**
  115815. * Renders the submesh passed in parameter to the generation map.
  115816. */
  115817. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  115818. /**
  115819. * Rebuild the required buffers.
  115820. * @hidden Internal use only.
  115821. */
  115822. _rebuild(): void;
  115823. /**
  115824. * Dispose only the render target textures and post process.
  115825. */
  115826. private _disposeTextureAndPostProcesses;
  115827. /**
  115828. * Dispose the highlight layer and free resources.
  115829. */
  115830. dispose(): void;
  115831. /**
  115832. * Gets the class name of the effect layer
  115833. * @returns the string with the class name of the effect layer
  115834. */
  115835. getClassName(): string;
  115836. /**
  115837. * Creates an effect layer from parsed effect layer data
  115838. * @param parsedEffectLayer defines effect layer data
  115839. * @param scene defines the current scene
  115840. * @param rootUrl defines the root URL containing the effect layer information
  115841. * @returns a parsed effect Layer
  115842. */
  115843. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  115844. }
  115845. }
  115846. declare module BABYLON {
  115847. interface AbstractScene {
  115848. /**
  115849. * The list of effect layers (highlights/glow) added to the scene
  115850. * @see http://doc.babylonjs.com/how_to/highlight_layer
  115851. * @see http://doc.babylonjs.com/how_to/glow_layer
  115852. */
  115853. effectLayers: Array<EffectLayer>;
  115854. /**
  115855. * Removes the given effect layer from this scene.
  115856. * @param toRemove defines the effect layer to remove
  115857. * @returns the index of the removed effect layer
  115858. */
  115859. removeEffectLayer(toRemove: EffectLayer): number;
  115860. /**
  115861. * Adds the given effect layer to this scene
  115862. * @param newEffectLayer defines the effect layer to add
  115863. */
  115864. addEffectLayer(newEffectLayer: EffectLayer): void;
  115865. }
  115866. /**
  115867. * Defines the layer scene component responsible to manage any effect layers
  115868. * in a given scene.
  115869. */
  115870. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  115871. /**
  115872. * The component name helpfull to identify the component in the list of scene components.
  115873. */
  115874. readonly name: string;
  115875. /**
  115876. * The scene the component belongs to.
  115877. */
  115878. scene: Scene;
  115879. private _engine;
  115880. private _renderEffects;
  115881. private _needStencil;
  115882. private _previousStencilState;
  115883. /**
  115884. * Creates a new instance of the component for the given scene
  115885. * @param scene Defines the scene to register the component in
  115886. */
  115887. constructor(scene: Scene);
  115888. /**
  115889. * Registers the component in a given scene
  115890. */
  115891. register(): void;
  115892. /**
  115893. * Rebuilds the elements related to this component in case of
  115894. * context lost for instance.
  115895. */
  115896. rebuild(): void;
  115897. /**
  115898. * Serializes the component data to the specified json object
  115899. * @param serializationObject The object to serialize to
  115900. */
  115901. serialize(serializationObject: any): void;
  115902. /**
  115903. * Adds all the elements from the container to the scene
  115904. * @param container the container holding the elements
  115905. */
  115906. addFromContainer(container: AbstractScene): void;
  115907. /**
  115908. * Removes all the elements in the container from the scene
  115909. * @param container contains the elements to remove
  115910. * @param dispose if the removed element should be disposed (default: false)
  115911. */
  115912. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115913. /**
  115914. * Disposes the component and the associated ressources.
  115915. */
  115916. dispose(): void;
  115917. private _isReadyForMesh;
  115918. private _renderMainTexture;
  115919. private _setStencil;
  115920. private _setStencilBack;
  115921. private _draw;
  115922. private _drawCamera;
  115923. private _drawRenderingGroup;
  115924. }
  115925. }
  115926. declare module BABYLON {
  115927. /** @hidden */
  115928. export var glowMapMergePixelShader: {
  115929. name: string;
  115930. shader: string;
  115931. };
  115932. }
  115933. declare module BABYLON {
  115934. /** @hidden */
  115935. export var glowMapMergeVertexShader: {
  115936. name: string;
  115937. shader: string;
  115938. };
  115939. }
  115940. declare module BABYLON {
  115941. interface AbstractScene {
  115942. /**
  115943. * Return a the first highlight layer of the scene with a given name.
  115944. * @param name The name of the highlight layer to look for.
  115945. * @return The highlight layer if found otherwise null.
  115946. */
  115947. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  115948. }
  115949. /**
  115950. * Glow layer options. This helps customizing the behaviour
  115951. * of the glow layer.
  115952. */
  115953. export interface IGlowLayerOptions {
  115954. /**
  115955. * Multiplication factor apply to the canvas size to compute the render target size
  115956. * used to generated the glowing objects (the smaller the faster).
  115957. */
  115958. mainTextureRatio: number;
  115959. /**
  115960. * Enforces a fixed size texture to ensure resize independant blur.
  115961. */
  115962. mainTextureFixedSize?: number;
  115963. /**
  115964. * How big is the kernel of the blur texture.
  115965. */
  115966. blurKernelSize: number;
  115967. /**
  115968. * The camera attached to the layer.
  115969. */
  115970. camera: Nullable<Camera>;
  115971. /**
  115972. * Enable MSAA by chosing the number of samples.
  115973. */
  115974. mainTextureSamples?: number;
  115975. /**
  115976. * The rendering group to draw the layer in.
  115977. */
  115978. renderingGroupId: number;
  115979. }
  115980. /**
  115981. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  115982. *
  115983. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  115984. * glowy meshes to your scene.
  115985. *
  115986. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  115987. */
  115988. export class GlowLayer extends EffectLayer {
  115989. /**
  115990. * Effect Name of the layer.
  115991. */
  115992. static readonly EffectName: string;
  115993. /**
  115994. * The default blur kernel size used for the glow.
  115995. */
  115996. static DefaultBlurKernelSize: number;
  115997. /**
  115998. * The default texture size ratio used for the glow.
  115999. */
  116000. static DefaultTextureRatio: number;
  116001. /**
  116002. * Sets the kernel size of the blur.
  116003. */
  116004. /**
  116005. * Gets the kernel size of the blur.
  116006. */
  116007. blurKernelSize: number;
  116008. /**
  116009. * Sets the glow intensity.
  116010. */
  116011. /**
  116012. * Gets the glow intensity.
  116013. */
  116014. intensity: number;
  116015. private _options;
  116016. private _intensity;
  116017. private _horizontalBlurPostprocess1;
  116018. private _verticalBlurPostprocess1;
  116019. private _horizontalBlurPostprocess2;
  116020. private _verticalBlurPostprocess2;
  116021. private _blurTexture1;
  116022. private _blurTexture2;
  116023. private _postProcesses1;
  116024. private _postProcesses2;
  116025. private _includedOnlyMeshes;
  116026. private _excludedMeshes;
  116027. /**
  116028. * Callback used to let the user override the color selection on a per mesh basis
  116029. */
  116030. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  116031. /**
  116032. * Callback used to let the user override the texture selection on a per mesh basis
  116033. */
  116034. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  116035. /**
  116036. * Instantiates a new glow Layer and references it to the scene.
  116037. * @param name The name of the layer
  116038. * @param scene The scene to use the layer in
  116039. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  116040. */
  116041. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  116042. /**
  116043. * Get the effect name of the layer.
  116044. * @return The effect name
  116045. */
  116046. getEffectName(): string;
  116047. /**
  116048. * Create the merge effect. This is the shader use to blit the information back
  116049. * to the main canvas at the end of the scene rendering.
  116050. */
  116051. protected _createMergeEffect(): Effect;
  116052. /**
  116053. * Creates the render target textures and post processes used in the glow layer.
  116054. */
  116055. protected _createTextureAndPostProcesses(): void;
  116056. /**
  116057. * Checks for the readiness of the element composing the layer.
  116058. * @param subMesh the mesh to check for
  116059. * @param useInstances specify wether or not to use instances to render the mesh
  116060. * @param emissiveTexture the associated emissive texture used to generate the glow
  116061. * @return true if ready otherwise, false
  116062. */
  116063. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116064. /**
  116065. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116066. */
  116067. needStencil(): boolean;
  116068. /**
  116069. * Returns true if the mesh can be rendered, otherwise false.
  116070. * @param mesh The mesh to render
  116071. * @param material The material used on the mesh
  116072. * @returns true if it can be rendered otherwise false
  116073. */
  116074. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116075. /**
  116076. * Implementation specific of rendering the generating effect on the main canvas.
  116077. * @param effect The effect used to render through
  116078. */
  116079. protected _internalRender(effect: Effect): void;
  116080. /**
  116081. * Sets the required values for both the emissive texture and and the main color.
  116082. */
  116083. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116084. /**
  116085. * Returns true if the mesh should render, otherwise false.
  116086. * @param mesh The mesh to render
  116087. * @returns true if it should render otherwise false
  116088. */
  116089. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116090. /**
  116091. * Adds specific effects defines.
  116092. * @param defines The defines to add specifics to.
  116093. */
  116094. protected _addCustomEffectDefines(defines: string[]): void;
  116095. /**
  116096. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  116097. * @param mesh The mesh to exclude from the glow layer
  116098. */
  116099. addExcludedMesh(mesh: Mesh): void;
  116100. /**
  116101. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  116102. * @param mesh The mesh to remove
  116103. */
  116104. removeExcludedMesh(mesh: Mesh): void;
  116105. /**
  116106. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  116107. * @param mesh The mesh to include in the glow layer
  116108. */
  116109. addIncludedOnlyMesh(mesh: Mesh): void;
  116110. /**
  116111. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  116112. * @param mesh The mesh to remove
  116113. */
  116114. removeIncludedOnlyMesh(mesh: Mesh): void;
  116115. /**
  116116. * Determine if a given mesh will be used in the glow layer
  116117. * @param mesh The mesh to test
  116118. * @returns true if the mesh will be highlighted by the current glow layer
  116119. */
  116120. hasMesh(mesh: AbstractMesh): boolean;
  116121. /**
  116122. * Free any resources and references associated to a mesh.
  116123. * Internal use
  116124. * @param mesh The mesh to free.
  116125. * @hidden
  116126. */
  116127. _disposeMesh(mesh: Mesh): void;
  116128. /**
  116129. * Gets the class name of the effect layer
  116130. * @returns the string with the class name of the effect layer
  116131. */
  116132. getClassName(): string;
  116133. /**
  116134. * Serializes this glow layer
  116135. * @returns a serialized glow layer object
  116136. */
  116137. serialize(): any;
  116138. /**
  116139. * Creates a Glow Layer from parsed glow layer data
  116140. * @param parsedGlowLayer defines glow layer data
  116141. * @param scene defines the current scene
  116142. * @param rootUrl defines the root URL containing the glow layer information
  116143. * @returns a parsed Glow Layer
  116144. */
  116145. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  116146. }
  116147. }
  116148. declare module BABYLON {
  116149. /** @hidden */
  116150. export var glowBlurPostProcessPixelShader: {
  116151. name: string;
  116152. shader: string;
  116153. };
  116154. }
  116155. declare module BABYLON {
  116156. interface AbstractScene {
  116157. /**
  116158. * Return a the first highlight layer of the scene with a given name.
  116159. * @param name The name of the highlight layer to look for.
  116160. * @return The highlight layer if found otherwise null.
  116161. */
  116162. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  116163. }
  116164. /**
  116165. * Highlight layer options. This helps customizing the behaviour
  116166. * of the highlight layer.
  116167. */
  116168. export interface IHighlightLayerOptions {
  116169. /**
  116170. * Multiplication factor apply to the canvas size to compute the render target size
  116171. * used to generated the glowing objects (the smaller the faster).
  116172. */
  116173. mainTextureRatio: number;
  116174. /**
  116175. * Enforces a fixed size texture to ensure resize independant blur.
  116176. */
  116177. mainTextureFixedSize?: number;
  116178. /**
  116179. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  116180. * of the picture to blur (the smaller the faster).
  116181. */
  116182. blurTextureSizeRatio: number;
  116183. /**
  116184. * How big in texel of the blur texture is the vertical blur.
  116185. */
  116186. blurVerticalSize: number;
  116187. /**
  116188. * How big in texel of the blur texture is the horizontal blur.
  116189. */
  116190. blurHorizontalSize: number;
  116191. /**
  116192. * Alpha blending mode used to apply the blur. Default is combine.
  116193. */
  116194. alphaBlendingMode: number;
  116195. /**
  116196. * The camera attached to the layer.
  116197. */
  116198. camera: Nullable<Camera>;
  116199. /**
  116200. * Should we display highlight as a solid stroke?
  116201. */
  116202. isStroke?: boolean;
  116203. /**
  116204. * The rendering group to draw the layer in.
  116205. */
  116206. renderingGroupId: number;
  116207. }
  116208. /**
  116209. * The highlight layer Helps adding a glow effect around a mesh.
  116210. *
  116211. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116212. * glowy meshes to your scene.
  116213. *
  116214. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  116215. */
  116216. export class HighlightLayer extends EffectLayer {
  116217. name: string;
  116218. /**
  116219. * Effect Name of the highlight layer.
  116220. */
  116221. static readonly EffectName: string;
  116222. /**
  116223. * The neutral color used during the preparation of the glow effect.
  116224. * This is black by default as the blend operation is a blend operation.
  116225. */
  116226. static NeutralColor: Color4;
  116227. /**
  116228. * Stencil value used for glowing meshes.
  116229. */
  116230. static GlowingMeshStencilReference: number;
  116231. /**
  116232. * Stencil value used for the other meshes in the scene.
  116233. */
  116234. static NormalMeshStencilReference: number;
  116235. /**
  116236. * Specifies whether or not the inner glow is ACTIVE in the layer.
  116237. */
  116238. innerGlow: boolean;
  116239. /**
  116240. * Specifies whether or not the outer glow is ACTIVE in the layer.
  116241. */
  116242. outerGlow: boolean;
  116243. /**
  116244. * Specifies the horizontal size of the blur.
  116245. */
  116246. /**
  116247. * Gets the horizontal size of the blur.
  116248. */
  116249. blurHorizontalSize: number;
  116250. /**
  116251. * Specifies the vertical size of the blur.
  116252. */
  116253. /**
  116254. * Gets the vertical size of the blur.
  116255. */
  116256. blurVerticalSize: number;
  116257. /**
  116258. * An event triggered when the highlight layer is being blurred.
  116259. */
  116260. onBeforeBlurObservable: Observable<HighlightLayer>;
  116261. /**
  116262. * An event triggered when the highlight layer has been blurred.
  116263. */
  116264. onAfterBlurObservable: Observable<HighlightLayer>;
  116265. private _instanceGlowingMeshStencilReference;
  116266. private _options;
  116267. private _downSamplePostprocess;
  116268. private _horizontalBlurPostprocess;
  116269. private _verticalBlurPostprocess;
  116270. private _blurTexture;
  116271. private _meshes;
  116272. private _excludedMeshes;
  116273. /**
  116274. * Instantiates a new highlight Layer and references it to the scene..
  116275. * @param name The name of the layer
  116276. * @param scene The scene to use the layer in
  116277. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  116278. */
  116279. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  116280. /**
  116281. * Get the effect name of the layer.
  116282. * @return The effect name
  116283. */
  116284. getEffectName(): string;
  116285. /**
  116286. * Create the merge effect. This is the shader use to blit the information back
  116287. * to the main canvas at the end of the scene rendering.
  116288. */
  116289. protected _createMergeEffect(): Effect;
  116290. /**
  116291. * Creates the render target textures and post processes used in the highlight layer.
  116292. */
  116293. protected _createTextureAndPostProcesses(): void;
  116294. /**
  116295. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116296. */
  116297. needStencil(): boolean;
  116298. /**
  116299. * Checks for the readiness of the element composing the layer.
  116300. * @param subMesh the mesh to check for
  116301. * @param useInstances specify wether or not to use instances to render the mesh
  116302. * @param emissiveTexture the associated emissive texture used to generate the glow
  116303. * @return true if ready otherwise, false
  116304. */
  116305. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116306. /**
  116307. * Implementation specific of rendering the generating effect on the main canvas.
  116308. * @param effect The effect used to render through
  116309. */
  116310. protected _internalRender(effect: Effect): void;
  116311. /**
  116312. * Returns true if the layer contains information to display, otherwise false.
  116313. */
  116314. shouldRender(): boolean;
  116315. /**
  116316. * Returns true if the mesh should render, otherwise false.
  116317. * @param mesh The mesh to render
  116318. * @returns true if it should render otherwise false
  116319. */
  116320. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116321. /**
  116322. * Sets the required values for both the emissive texture and and the main color.
  116323. */
  116324. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116325. /**
  116326. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  116327. * @param mesh The mesh to exclude from the highlight layer
  116328. */
  116329. addExcludedMesh(mesh: Mesh): void;
  116330. /**
  116331. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  116332. * @param mesh The mesh to highlight
  116333. */
  116334. removeExcludedMesh(mesh: Mesh): void;
  116335. /**
  116336. * Determine if a given mesh will be highlighted by the current HighlightLayer
  116337. * @param mesh mesh to test
  116338. * @returns true if the mesh will be highlighted by the current HighlightLayer
  116339. */
  116340. hasMesh(mesh: AbstractMesh): boolean;
  116341. /**
  116342. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  116343. * @param mesh The mesh to highlight
  116344. * @param color The color of the highlight
  116345. * @param glowEmissiveOnly Extract the glow from the emissive texture
  116346. */
  116347. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  116348. /**
  116349. * Remove a mesh from the highlight layer in order to make it stop glowing.
  116350. * @param mesh The mesh to highlight
  116351. */
  116352. removeMesh(mesh: Mesh): void;
  116353. /**
  116354. * Force the stencil to the normal expected value for none glowing parts
  116355. */
  116356. private _defaultStencilReference;
  116357. /**
  116358. * Free any resources and references associated to a mesh.
  116359. * Internal use
  116360. * @param mesh The mesh to free.
  116361. * @hidden
  116362. */
  116363. _disposeMesh(mesh: Mesh): void;
  116364. /**
  116365. * Dispose the highlight layer and free resources.
  116366. */
  116367. dispose(): void;
  116368. /**
  116369. * Gets the class name of the effect layer
  116370. * @returns the string with the class name of the effect layer
  116371. */
  116372. getClassName(): string;
  116373. /**
  116374. * Serializes this Highlight layer
  116375. * @returns a serialized Highlight layer object
  116376. */
  116377. serialize(): any;
  116378. /**
  116379. * Creates a Highlight layer from parsed Highlight layer data
  116380. * @param parsedHightlightLayer defines the Highlight layer data
  116381. * @param scene defines the current scene
  116382. * @param rootUrl defines the root URL containing the Highlight layer information
  116383. * @returns a parsed Highlight layer
  116384. */
  116385. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  116386. }
  116387. }
  116388. declare module BABYLON {
  116389. interface AbstractScene {
  116390. /**
  116391. * The list of layers (background and foreground) of the scene
  116392. */
  116393. layers: Array<Layer>;
  116394. }
  116395. /**
  116396. * Defines the layer scene component responsible to manage any layers
  116397. * in a given scene.
  116398. */
  116399. export class LayerSceneComponent implements ISceneComponent {
  116400. /**
  116401. * The component name helpfull to identify the component in the list of scene components.
  116402. */
  116403. readonly name: string;
  116404. /**
  116405. * The scene the component belongs to.
  116406. */
  116407. scene: Scene;
  116408. private _engine;
  116409. /**
  116410. * Creates a new instance of the component for the given scene
  116411. * @param scene Defines the scene to register the component in
  116412. */
  116413. constructor(scene: Scene);
  116414. /**
  116415. * Registers the component in a given scene
  116416. */
  116417. register(): void;
  116418. /**
  116419. * Rebuilds the elements related to this component in case of
  116420. * context lost for instance.
  116421. */
  116422. rebuild(): void;
  116423. /**
  116424. * Disposes the component and the associated ressources.
  116425. */
  116426. dispose(): void;
  116427. private _draw;
  116428. private _drawCameraPredicate;
  116429. private _drawCameraBackground;
  116430. private _drawCameraForeground;
  116431. private _drawRenderTargetPredicate;
  116432. private _drawRenderTargetBackground;
  116433. private _drawRenderTargetForeground;
  116434. /**
  116435. * Adds all the elements from the container to the scene
  116436. * @param container the container holding the elements
  116437. */
  116438. addFromContainer(container: AbstractScene): void;
  116439. /**
  116440. * Removes all the elements in the container from the scene
  116441. * @param container contains the elements to remove
  116442. * @param dispose if the removed element should be disposed (default: false)
  116443. */
  116444. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116445. }
  116446. }
  116447. declare module BABYLON {
  116448. /** @hidden */
  116449. export var layerPixelShader: {
  116450. name: string;
  116451. shader: string;
  116452. };
  116453. }
  116454. declare module BABYLON {
  116455. /** @hidden */
  116456. export var layerVertexShader: {
  116457. name: string;
  116458. shader: string;
  116459. };
  116460. }
  116461. declare module BABYLON {
  116462. /**
  116463. * This represents a full screen 2d layer.
  116464. * This can be useful to display a picture in the background of your scene for instance.
  116465. * @see https://www.babylonjs-playground.com/#08A2BS#1
  116466. */
  116467. export class Layer {
  116468. /**
  116469. * Define the name of the layer.
  116470. */
  116471. name: string;
  116472. /**
  116473. * Define the texture the layer should display.
  116474. */
  116475. texture: Nullable<Texture>;
  116476. /**
  116477. * Is the layer in background or foreground.
  116478. */
  116479. isBackground: boolean;
  116480. /**
  116481. * Define the color of the layer (instead of texture).
  116482. */
  116483. color: Color4;
  116484. /**
  116485. * Define the scale of the layer in order to zoom in out of the texture.
  116486. */
  116487. scale: Vector2;
  116488. /**
  116489. * Define an offset for the layer in order to shift the texture.
  116490. */
  116491. offset: Vector2;
  116492. /**
  116493. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  116494. */
  116495. alphaBlendingMode: number;
  116496. /**
  116497. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  116498. * Alpha test will not mix with the background color in case of transparency.
  116499. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  116500. */
  116501. alphaTest: boolean;
  116502. /**
  116503. * Define a mask to restrict the layer to only some of the scene cameras.
  116504. */
  116505. layerMask: number;
  116506. /**
  116507. * Define the list of render target the layer is visible into.
  116508. */
  116509. renderTargetTextures: RenderTargetTexture[];
  116510. /**
  116511. * Define if the layer is only used in renderTarget or if it also
  116512. * renders in the main frame buffer of the canvas.
  116513. */
  116514. renderOnlyInRenderTargetTextures: boolean;
  116515. private _scene;
  116516. private _vertexBuffers;
  116517. private _indexBuffer;
  116518. private _effect;
  116519. private _alphaTestEffect;
  116520. /**
  116521. * An event triggered when the layer is disposed.
  116522. */
  116523. onDisposeObservable: Observable<Layer>;
  116524. private _onDisposeObserver;
  116525. /**
  116526. * Back compatibility with callback before the onDisposeObservable existed.
  116527. * The set callback will be triggered when the layer has been disposed.
  116528. */
  116529. onDispose: () => void;
  116530. /**
  116531. * An event triggered before rendering the scene
  116532. */
  116533. onBeforeRenderObservable: Observable<Layer>;
  116534. private _onBeforeRenderObserver;
  116535. /**
  116536. * Back compatibility with callback before the onBeforeRenderObservable existed.
  116537. * The set callback will be triggered just before rendering the layer.
  116538. */
  116539. onBeforeRender: () => void;
  116540. /**
  116541. * An event triggered after rendering the scene
  116542. */
  116543. onAfterRenderObservable: Observable<Layer>;
  116544. private _onAfterRenderObserver;
  116545. /**
  116546. * Back compatibility with callback before the onAfterRenderObservable existed.
  116547. * The set callback will be triggered just after rendering the layer.
  116548. */
  116549. onAfterRender: () => void;
  116550. /**
  116551. * Instantiates a new layer.
  116552. * This represents a full screen 2d layer.
  116553. * This can be useful to display a picture in the background of your scene for instance.
  116554. * @see https://www.babylonjs-playground.com/#08A2BS#1
  116555. * @param name Define the name of the layer in the scene
  116556. * @param imgUrl Define the url of the texture to display in the layer
  116557. * @param scene Define the scene the layer belongs to
  116558. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  116559. * @param color Defines a color for the layer
  116560. */
  116561. constructor(
  116562. /**
  116563. * Define the name of the layer.
  116564. */
  116565. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  116566. private _createIndexBuffer;
  116567. /** @hidden */
  116568. _rebuild(): void;
  116569. /**
  116570. * Renders the layer in the scene.
  116571. */
  116572. render(): void;
  116573. /**
  116574. * Disposes and releases the associated ressources.
  116575. */
  116576. dispose(): void;
  116577. }
  116578. }
  116579. declare module BABYLON {
  116580. /** @hidden */
  116581. export var lensFlarePixelShader: {
  116582. name: string;
  116583. shader: string;
  116584. };
  116585. }
  116586. declare module BABYLON {
  116587. /** @hidden */
  116588. export var lensFlareVertexShader: {
  116589. name: string;
  116590. shader: string;
  116591. };
  116592. }
  116593. declare module BABYLON {
  116594. /**
  116595. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  116596. * It is usually composed of several `lensFlare`.
  116597. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116598. */
  116599. export class LensFlareSystem {
  116600. /**
  116601. * Define the name of the lens flare system
  116602. */
  116603. name: string;
  116604. /**
  116605. * List of lens flares used in this system.
  116606. */
  116607. lensFlares: LensFlare[];
  116608. /**
  116609. * Define a limit from the border the lens flare can be visible.
  116610. */
  116611. borderLimit: number;
  116612. /**
  116613. * Define a viewport border we do not want to see the lens flare in.
  116614. */
  116615. viewportBorder: number;
  116616. /**
  116617. * Define a predicate which could limit the list of meshes able to occlude the effect.
  116618. */
  116619. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  116620. /**
  116621. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  116622. */
  116623. layerMask: number;
  116624. /**
  116625. * Define the id of the lens flare system in the scene.
  116626. * (equal to name by default)
  116627. */
  116628. id: string;
  116629. private _scene;
  116630. private _emitter;
  116631. private _vertexBuffers;
  116632. private _indexBuffer;
  116633. private _effect;
  116634. private _positionX;
  116635. private _positionY;
  116636. private _isEnabled;
  116637. /** @hidden */
  116638. static _SceneComponentInitialization: (scene: Scene) => void;
  116639. /**
  116640. * Instantiates a lens flare system.
  116641. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  116642. * It is usually composed of several `lensFlare`.
  116643. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116644. * @param name Define the name of the lens flare system in the scene
  116645. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  116646. * @param scene Define the scene the lens flare system belongs to
  116647. */
  116648. constructor(
  116649. /**
  116650. * Define the name of the lens flare system
  116651. */
  116652. name: string, emitter: any, scene: Scene);
  116653. /**
  116654. * Define if the lens flare system is enabled.
  116655. */
  116656. isEnabled: boolean;
  116657. /**
  116658. * Get the scene the effects belongs to.
  116659. * @returns the scene holding the lens flare system
  116660. */
  116661. getScene(): Scene;
  116662. /**
  116663. * Get the emitter of the lens flare system.
  116664. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  116665. * @returns the emitter of the lens flare system
  116666. */
  116667. getEmitter(): any;
  116668. /**
  116669. * Set the emitter of the lens flare system.
  116670. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  116671. * @param newEmitter Define the new emitter of the system
  116672. */
  116673. setEmitter(newEmitter: any): void;
  116674. /**
  116675. * Get the lens flare system emitter position.
  116676. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  116677. * @returns the position
  116678. */
  116679. getEmitterPosition(): Vector3;
  116680. /**
  116681. * @hidden
  116682. */
  116683. computeEffectivePosition(globalViewport: Viewport): boolean;
  116684. /** @hidden */
  116685. _isVisible(): boolean;
  116686. /**
  116687. * @hidden
  116688. */
  116689. render(): boolean;
  116690. /**
  116691. * Dispose and release the lens flare with its associated resources.
  116692. */
  116693. dispose(): void;
  116694. /**
  116695. * Parse a lens flare system from a JSON repressentation
  116696. * @param parsedLensFlareSystem Define the JSON to parse
  116697. * @param scene Define the scene the parsed system should be instantiated in
  116698. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  116699. * @returns the parsed system
  116700. */
  116701. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  116702. /**
  116703. * Serialize the current Lens Flare System into a JSON representation.
  116704. * @returns the serialized JSON
  116705. */
  116706. serialize(): any;
  116707. }
  116708. }
  116709. declare module BABYLON {
  116710. /**
  116711. * This represents one of the lens effect in a `lensFlareSystem`.
  116712. * It controls one of the indiviual texture used in the effect.
  116713. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116714. */
  116715. export class LensFlare {
  116716. /**
  116717. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  116718. */
  116719. size: number;
  116720. /**
  116721. * 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.
  116722. */
  116723. position: number;
  116724. /**
  116725. * Define the lens color.
  116726. */
  116727. color: Color3;
  116728. /**
  116729. * Define the lens texture.
  116730. */
  116731. texture: Nullable<Texture>;
  116732. /**
  116733. * Define the alpha mode to render this particular lens.
  116734. */
  116735. alphaMode: number;
  116736. private _system;
  116737. /**
  116738. * Creates a new Lens Flare.
  116739. * This represents one of the lens effect in a `lensFlareSystem`.
  116740. * It controls one of the indiviual texture used in the effect.
  116741. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116742. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  116743. * @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.
  116744. * @param color Define the lens color
  116745. * @param imgUrl Define the lens texture url
  116746. * @param system Define the `lensFlareSystem` this flare is part of
  116747. * @returns The newly created Lens Flare
  116748. */
  116749. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  116750. /**
  116751. * Instantiates a new Lens Flare.
  116752. * This represents one of the lens effect in a `lensFlareSystem`.
  116753. * It controls one of the indiviual texture used in the effect.
  116754. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116755. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  116756. * @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.
  116757. * @param color Define the lens color
  116758. * @param imgUrl Define the lens texture url
  116759. * @param system Define the `lensFlareSystem` this flare is part of
  116760. */
  116761. constructor(
  116762. /**
  116763. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  116764. */
  116765. size: number,
  116766. /**
  116767. * 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.
  116768. */
  116769. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  116770. /**
  116771. * Dispose and release the lens flare with its associated resources.
  116772. */
  116773. dispose(): void;
  116774. }
  116775. }
  116776. declare module BABYLON {
  116777. interface AbstractScene {
  116778. /**
  116779. * The list of lens flare system added to the scene
  116780. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116781. */
  116782. lensFlareSystems: Array<LensFlareSystem>;
  116783. /**
  116784. * Removes the given lens flare system from this scene.
  116785. * @param toRemove The lens flare system to remove
  116786. * @returns The index of the removed lens flare system
  116787. */
  116788. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  116789. /**
  116790. * Adds the given lens flare system to this scene
  116791. * @param newLensFlareSystem The lens flare system to add
  116792. */
  116793. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  116794. /**
  116795. * Gets a lens flare system using its name
  116796. * @param name defines the name to look for
  116797. * @returns the lens flare system or null if not found
  116798. */
  116799. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  116800. /**
  116801. * Gets a lens flare system using its id
  116802. * @param id defines the id to look for
  116803. * @returns the lens flare system or null if not found
  116804. */
  116805. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  116806. }
  116807. /**
  116808. * Defines the lens flare scene component responsible to manage any lens flares
  116809. * in a given scene.
  116810. */
  116811. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  116812. /**
  116813. * The component name helpfull to identify the component in the list of scene components.
  116814. */
  116815. readonly name: string;
  116816. /**
  116817. * The scene the component belongs to.
  116818. */
  116819. scene: Scene;
  116820. /**
  116821. * Creates a new instance of the component for the given scene
  116822. * @param scene Defines the scene to register the component in
  116823. */
  116824. constructor(scene: Scene);
  116825. /**
  116826. * Registers the component in a given scene
  116827. */
  116828. register(): void;
  116829. /**
  116830. * Rebuilds the elements related to this component in case of
  116831. * context lost for instance.
  116832. */
  116833. rebuild(): void;
  116834. /**
  116835. * Adds all the elements from the container to the scene
  116836. * @param container the container holding the elements
  116837. */
  116838. addFromContainer(container: AbstractScene): void;
  116839. /**
  116840. * Removes all the elements in the container from the scene
  116841. * @param container contains the elements to remove
  116842. * @param dispose if the removed element should be disposed (default: false)
  116843. */
  116844. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116845. /**
  116846. * Serializes the component data to the specified json object
  116847. * @param serializationObject The object to serialize to
  116848. */
  116849. serialize(serializationObject: any): void;
  116850. /**
  116851. * Disposes the component and the associated ressources.
  116852. */
  116853. dispose(): void;
  116854. private _draw;
  116855. }
  116856. }
  116857. declare module BABYLON {
  116858. /**
  116859. * Defines the shadow generator component responsible to manage any shadow generators
  116860. * in a given scene.
  116861. */
  116862. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  116863. /**
  116864. * The component name helpfull to identify the component in the list of scene components.
  116865. */
  116866. readonly name: string;
  116867. /**
  116868. * The scene the component belongs to.
  116869. */
  116870. scene: Scene;
  116871. /**
  116872. * Creates a new instance of the component for the given scene
  116873. * @param scene Defines the scene to register the component in
  116874. */
  116875. constructor(scene: Scene);
  116876. /**
  116877. * Registers the component in a given scene
  116878. */
  116879. register(): void;
  116880. /**
  116881. * Rebuilds the elements related to this component in case of
  116882. * context lost for instance.
  116883. */
  116884. rebuild(): void;
  116885. /**
  116886. * Serializes the component data to the specified json object
  116887. * @param serializationObject The object to serialize to
  116888. */
  116889. serialize(serializationObject: any): void;
  116890. /**
  116891. * Adds all the elements from the container to the scene
  116892. * @param container the container holding the elements
  116893. */
  116894. addFromContainer(container: AbstractScene): void;
  116895. /**
  116896. * Removes all the elements in the container from the scene
  116897. * @param container contains the elements to remove
  116898. * @param dispose if the removed element should be disposed (default: false)
  116899. */
  116900. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116901. /**
  116902. * Rebuilds the elements related to this component in case of
  116903. * context lost for instance.
  116904. */
  116905. dispose(): void;
  116906. private _gatherRenderTargets;
  116907. }
  116908. }
  116909. declare module BABYLON {
  116910. /**
  116911. * A point light is a light defined by an unique point in world space.
  116912. * The light is emitted in every direction from this point.
  116913. * A good example of a point light is a standard light bulb.
  116914. * Documentation: https://doc.babylonjs.com/babylon101/lights
  116915. */
  116916. export class PointLight extends ShadowLight {
  116917. private _shadowAngle;
  116918. /**
  116919. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  116920. * This specifies what angle the shadow will use to be created.
  116921. *
  116922. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  116923. */
  116924. /**
  116925. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  116926. * This specifies what angle the shadow will use to be created.
  116927. *
  116928. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  116929. */
  116930. shadowAngle: number;
  116931. /**
  116932. * Gets the direction if it has been set.
  116933. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  116934. */
  116935. /**
  116936. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  116937. */
  116938. direction: Vector3;
  116939. /**
  116940. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  116941. * A PointLight emits the light in every direction.
  116942. * It can cast shadows.
  116943. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  116944. * ```javascript
  116945. * var pointLight = new PointLight("pl", camera.position, scene);
  116946. * ```
  116947. * Documentation : https://doc.babylonjs.com/babylon101/lights
  116948. * @param name The light friendly name
  116949. * @param position The position of the point light in the scene
  116950. * @param scene The scene the lights belongs to
  116951. */
  116952. constructor(name: string, position: Vector3, scene: Scene);
  116953. /**
  116954. * Returns the string "PointLight"
  116955. * @returns the class name
  116956. */
  116957. getClassName(): string;
  116958. /**
  116959. * Returns the integer 0.
  116960. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  116961. */
  116962. getTypeID(): number;
  116963. /**
  116964. * Specifies wether or not the shadowmap should be a cube texture.
  116965. * @returns true if the shadowmap needs to be a cube texture.
  116966. */
  116967. needCube(): boolean;
  116968. /**
  116969. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  116970. * @param faceIndex The index of the face we are computed the direction to generate shadow
  116971. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  116972. */
  116973. getShadowDirection(faceIndex?: number): Vector3;
  116974. /**
  116975. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  116976. * - fov = PI / 2
  116977. * - aspect ratio : 1.0
  116978. * - z-near and far equal to the active camera minZ and maxZ.
  116979. * Returns the PointLight.
  116980. */
  116981. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  116982. protected _buildUniformLayout(): void;
  116983. /**
  116984. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  116985. * @param effect The effect to update
  116986. * @param lightIndex The index of the light in the effect to update
  116987. * @returns The point light
  116988. */
  116989. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  116990. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  116991. /**
  116992. * Prepares the list of defines specific to the light type.
  116993. * @param defines the list of defines
  116994. * @param lightIndex defines the index of the light for the effect
  116995. */
  116996. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  116997. }
  116998. }
  116999. declare module BABYLON {
  117000. /**
  117001. * Header information of HDR texture files.
  117002. */
  117003. export interface HDRInfo {
  117004. /**
  117005. * The height of the texture in pixels.
  117006. */
  117007. height: number;
  117008. /**
  117009. * The width of the texture in pixels.
  117010. */
  117011. width: number;
  117012. /**
  117013. * The index of the beginning of the data in the binary file.
  117014. */
  117015. dataPosition: number;
  117016. }
  117017. /**
  117018. * This groups tools to convert HDR texture to native colors array.
  117019. */
  117020. export class HDRTools {
  117021. private static Ldexp;
  117022. private static Rgbe2float;
  117023. private static readStringLine;
  117024. /**
  117025. * Reads header information from an RGBE texture stored in a native array.
  117026. * More information on this format are available here:
  117027. * https://en.wikipedia.org/wiki/RGBE_image_format
  117028. *
  117029. * @param uint8array The binary file stored in native array.
  117030. * @return The header information.
  117031. */
  117032. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  117033. /**
  117034. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  117035. * This RGBE texture needs to store the information as a panorama.
  117036. *
  117037. * More information on this format are available here:
  117038. * https://en.wikipedia.org/wiki/RGBE_image_format
  117039. *
  117040. * @param buffer The binary file stored in an array buffer.
  117041. * @param size The expected size of the extracted cubemap.
  117042. * @return The Cube Map information.
  117043. */
  117044. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  117045. /**
  117046. * Returns the pixels data extracted from an RGBE texture.
  117047. * This pixels will be stored left to right up to down in the R G B order in one array.
  117048. *
  117049. * More information on this format are available here:
  117050. * https://en.wikipedia.org/wiki/RGBE_image_format
  117051. *
  117052. * @param uint8array The binary file stored in an array buffer.
  117053. * @param hdrInfo The header information of the file.
  117054. * @return The pixels data in RGB right to left up to down order.
  117055. */
  117056. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  117057. private static RGBE_ReadPixels_RLE;
  117058. }
  117059. }
  117060. declare module BABYLON {
  117061. /**
  117062. * This represents a texture coming from an HDR input.
  117063. *
  117064. * The only supported format is currently panorama picture stored in RGBE format.
  117065. * Example of such files can be found on HDRLib: http://hdrlib.com/
  117066. */
  117067. export class HDRCubeTexture extends BaseTexture {
  117068. private static _facesMapping;
  117069. private _generateHarmonics;
  117070. private _noMipmap;
  117071. private _textureMatrix;
  117072. private _size;
  117073. private _onLoad;
  117074. private _onError;
  117075. /**
  117076. * The texture URL.
  117077. */
  117078. url: string;
  117079. /**
  117080. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  117081. */
  117082. coordinatesMode: number;
  117083. protected _isBlocking: boolean;
  117084. /**
  117085. * Sets wether or not the texture is blocking during loading.
  117086. */
  117087. /**
  117088. * Gets wether or not the texture is blocking during loading.
  117089. */
  117090. isBlocking: boolean;
  117091. protected _rotationY: number;
  117092. /**
  117093. * Sets texture matrix rotation angle around Y axis in radians.
  117094. */
  117095. /**
  117096. * Gets texture matrix rotation angle around Y axis radians.
  117097. */
  117098. rotationY: number;
  117099. /**
  117100. * Gets or sets the center of the bounding box associated with the cube texture
  117101. * It must define where the camera used to render the texture was set
  117102. */
  117103. boundingBoxPosition: Vector3;
  117104. private _boundingBoxSize;
  117105. /**
  117106. * Gets or sets the size of the bounding box associated with the cube texture
  117107. * When defined, the cubemap will switch to local mode
  117108. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  117109. * @example https://www.babylonjs-playground.com/#RNASML
  117110. */
  117111. boundingBoxSize: Vector3;
  117112. /**
  117113. * Instantiates an HDRTexture from the following parameters.
  117114. *
  117115. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  117116. * @param scene The scene the texture will be used in
  117117. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117118. * @param noMipmap Forces to not generate the mipmap if true
  117119. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  117120. * @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)
  117121. * @param reserved Reserved flag for internal use.
  117122. */
  117123. 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>);
  117124. /**
  117125. * Get the current class name of the texture useful for serialization or dynamic coding.
  117126. * @returns "HDRCubeTexture"
  117127. */
  117128. getClassName(): string;
  117129. /**
  117130. * Occurs when the file is raw .hdr file.
  117131. */
  117132. private loadTexture;
  117133. clone(): HDRCubeTexture;
  117134. delayLoad(): void;
  117135. /**
  117136. * Get the texture reflection matrix used to rotate/transform the reflection.
  117137. * @returns the reflection matrix
  117138. */
  117139. getReflectionTextureMatrix(): Matrix;
  117140. /**
  117141. * Set the texture reflection matrix used to rotate/transform the reflection.
  117142. * @param value Define the reflection matrix to set
  117143. */
  117144. setReflectionTextureMatrix(value: Matrix): void;
  117145. /**
  117146. * Parses a JSON representation of an HDR Texture in order to create the texture
  117147. * @param parsedTexture Define the JSON representation
  117148. * @param scene Define the scene the texture should be created in
  117149. * @param rootUrl Define the root url in case we need to load relative dependencies
  117150. * @returns the newly created texture after parsing
  117151. */
  117152. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  117153. serialize(): any;
  117154. }
  117155. }
  117156. declare module BABYLON {
  117157. /**
  117158. * Class used to control physics engine
  117159. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117160. */
  117161. export class PhysicsEngine implements IPhysicsEngine {
  117162. private _physicsPlugin;
  117163. /**
  117164. * Global value used to control the smallest number supported by the simulation
  117165. */
  117166. static Epsilon: number;
  117167. private _impostors;
  117168. private _joints;
  117169. /**
  117170. * Gets the gravity vector used by the simulation
  117171. */
  117172. gravity: Vector3;
  117173. /**
  117174. * Factory used to create the default physics plugin.
  117175. * @returns The default physics plugin
  117176. */
  117177. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  117178. /**
  117179. * Creates a new Physics Engine
  117180. * @param gravity defines the gravity vector used by the simulation
  117181. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  117182. */
  117183. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  117184. /**
  117185. * Sets the gravity vector used by the simulation
  117186. * @param gravity defines the gravity vector to use
  117187. */
  117188. setGravity(gravity: Vector3): void;
  117189. /**
  117190. * Set the time step of the physics engine.
  117191. * Default is 1/60.
  117192. * To slow it down, enter 1/600 for example.
  117193. * To speed it up, 1/30
  117194. * @param newTimeStep defines the new timestep to apply to this world.
  117195. */
  117196. setTimeStep(newTimeStep?: number): void;
  117197. /**
  117198. * Get the time step of the physics engine.
  117199. * @returns the current time step
  117200. */
  117201. getTimeStep(): number;
  117202. /**
  117203. * Release all resources
  117204. */
  117205. dispose(): void;
  117206. /**
  117207. * Gets the name of the current physics plugin
  117208. * @returns the name of the plugin
  117209. */
  117210. getPhysicsPluginName(): string;
  117211. /**
  117212. * Adding a new impostor for the impostor tracking.
  117213. * This will be done by the impostor itself.
  117214. * @param impostor the impostor to add
  117215. */
  117216. addImpostor(impostor: PhysicsImpostor): void;
  117217. /**
  117218. * Remove an impostor from the engine.
  117219. * This impostor and its mesh will not longer be updated by the physics engine.
  117220. * @param impostor the impostor to remove
  117221. */
  117222. removeImpostor(impostor: PhysicsImpostor): void;
  117223. /**
  117224. * Add a joint to the physics engine
  117225. * @param mainImpostor defines the main impostor to which the joint is added.
  117226. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  117227. * @param joint defines the joint that will connect both impostors.
  117228. */
  117229. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117230. /**
  117231. * Removes a joint from the simulation
  117232. * @param mainImpostor defines the impostor used with the joint
  117233. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  117234. * @param joint defines the joint to remove
  117235. */
  117236. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117237. /**
  117238. * Called by the scene. No need to call it.
  117239. * @param delta defines the timespam between frames
  117240. */
  117241. _step(delta: number): void;
  117242. /**
  117243. * Gets the current plugin used to run the simulation
  117244. * @returns current plugin
  117245. */
  117246. getPhysicsPlugin(): IPhysicsEnginePlugin;
  117247. /**
  117248. * Gets the list of physic impostors
  117249. * @returns an array of PhysicsImpostor
  117250. */
  117251. getImpostors(): Array<PhysicsImpostor>;
  117252. /**
  117253. * Gets the impostor for a physics enabled object
  117254. * @param object defines the object impersonated by the impostor
  117255. * @returns the PhysicsImpostor or null if not found
  117256. */
  117257. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  117258. /**
  117259. * Gets the impostor for a physics body object
  117260. * @param body defines physics body used by the impostor
  117261. * @returns the PhysicsImpostor or null if not found
  117262. */
  117263. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  117264. /**
  117265. * Does a raycast in the physics world
  117266. * @param from when should the ray start?
  117267. * @param to when should the ray end?
  117268. * @returns PhysicsRaycastResult
  117269. */
  117270. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117271. }
  117272. }
  117273. declare module BABYLON {
  117274. /** @hidden */
  117275. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  117276. private _useDeltaForWorldStep;
  117277. world: any;
  117278. name: string;
  117279. private _physicsMaterials;
  117280. private _fixedTimeStep;
  117281. private _cannonRaycastResult;
  117282. private _raycastResult;
  117283. private _physicsBodysToRemoveAfterStep;
  117284. BJSCANNON: any;
  117285. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  117286. setGravity(gravity: Vector3): void;
  117287. setTimeStep(timeStep: number): void;
  117288. getTimeStep(): number;
  117289. executeStep(delta: number): void;
  117290. private _removeMarkedPhysicsBodiesFromWorld;
  117291. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117292. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117293. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117294. private _processChildMeshes;
  117295. removePhysicsBody(impostor: PhysicsImpostor): void;
  117296. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117297. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117298. private _addMaterial;
  117299. private _checkWithEpsilon;
  117300. private _createShape;
  117301. private _createHeightmap;
  117302. private _minus90X;
  117303. private _plus90X;
  117304. private _tmpPosition;
  117305. private _tmpDeltaPosition;
  117306. private _tmpUnityRotation;
  117307. private _updatePhysicsBodyTransformation;
  117308. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117309. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117310. isSupported(): boolean;
  117311. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117312. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117313. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117314. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117315. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117316. getBodyMass(impostor: PhysicsImpostor): number;
  117317. getBodyFriction(impostor: PhysicsImpostor): number;
  117318. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117319. getBodyRestitution(impostor: PhysicsImpostor): number;
  117320. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117321. sleepBody(impostor: PhysicsImpostor): void;
  117322. wakeUpBody(impostor: PhysicsImpostor): void;
  117323. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  117324. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  117325. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  117326. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117327. getRadius(impostor: PhysicsImpostor): number;
  117328. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117329. dispose(): void;
  117330. private _extendNamespace;
  117331. /**
  117332. * Does a raycast in the physics world
  117333. * @param from when should the ray start?
  117334. * @param to when should the ray end?
  117335. * @returns PhysicsRaycastResult
  117336. */
  117337. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117338. }
  117339. }
  117340. declare module BABYLON {
  117341. /** @hidden */
  117342. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  117343. world: any;
  117344. name: string;
  117345. BJSOIMO: any;
  117346. private _raycastResult;
  117347. constructor(iterations?: number, oimoInjection?: any);
  117348. setGravity(gravity: Vector3): void;
  117349. setTimeStep(timeStep: number): void;
  117350. getTimeStep(): number;
  117351. private _tmpImpostorsArray;
  117352. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117353. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117354. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117355. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117356. private _tmpPositionVector;
  117357. removePhysicsBody(impostor: PhysicsImpostor): void;
  117358. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117359. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117360. isSupported(): boolean;
  117361. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117362. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117363. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117364. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117365. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117366. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117367. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117368. getBodyMass(impostor: PhysicsImpostor): number;
  117369. getBodyFriction(impostor: PhysicsImpostor): number;
  117370. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117371. getBodyRestitution(impostor: PhysicsImpostor): number;
  117372. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117373. sleepBody(impostor: PhysicsImpostor): void;
  117374. wakeUpBody(impostor: PhysicsImpostor): void;
  117375. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  117376. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  117377. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  117378. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117379. getRadius(impostor: PhysicsImpostor): number;
  117380. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117381. dispose(): void;
  117382. /**
  117383. * Does a raycast in the physics world
  117384. * @param from when should the ray start?
  117385. * @param to when should the ray end?
  117386. * @returns PhysicsRaycastResult
  117387. */
  117388. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117389. }
  117390. }
  117391. declare module BABYLON {
  117392. /**
  117393. * Class containing static functions to help procedurally build meshes
  117394. */
  117395. export class RibbonBuilder {
  117396. /**
  117397. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117398. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  117399. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  117400. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  117401. * * 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
  117402. * * 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
  117403. * * 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
  117404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117405. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117406. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117407. * * 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
  117408. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  117409. * * 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
  117410. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  117411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117412. * @param name defines the name of the mesh
  117413. * @param options defines the options used to create the mesh
  117414. * @param scene defines the hosting scene
  117415. * @returns the ribbon mesh
  117416. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  117417. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117418. */
  117419. static CreateRibbon(name: string, options: {
  117420. pathArray: Vector3[][];
  117421. closeArray?: boolean;
  117422. closePath?: boolean;
  117423. offset?: number;
  117424. updatable?: boolean;
  117425. sideOrientation?: number;
  117426. frontUVs?: Vector4;
  117427. backUVs?: Vector4;
  117428. instance?: Mesh;
  117429. invertUV?: boolean;
  117430. uvs?: Vector2[];
  117431. colors?: Color4[];
  117432. }, scene?: Nullable<Scene>): Mesh;
  117433. }
  117434. }
  117435. declare module BABYLON {
  117436. /**
  117437. * Class containing static functions to help procedurally build meshes
  117438. */
  117439. export class ShapeBuilder {
  117440. /**
  117441. * 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.
  117442. * * 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.
  117443. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117444. * * 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.
  117445. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  117446. * * 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
  117447. * * 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
  117448. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  117449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117451. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  117452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117453. * @param name defines the name of the mesh
  117454. * @param options defines the options used to create the mesh
  117455. * @param scene defines the hosting scene
  117456. * @returns the extruded shape mesh
  117457. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117458. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117459. */
  117460. static ExtrudeShape(name: string, options: {
  117461. shape: Vector3[];
  117462. path: Vector3[];
  117463. scale?: number;
  117464. rotation?: number;
  117465. cap?: number;
  117466. updatable?: boolean;
  117467. sideOrientation?: number;
  117468. frontUVs?: Vector4;
  117469. backUVs?: Vector4;
  117470. instance?: Mesh;
  117471. invertUV?: boolean;
  117472. }, scene?: Nullable<Scene>): Mesh;
  117473. /**
  117474. * Creates an custom extruded shape mesh.
  117475. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  117476. * * 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.
  117477. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117478. * * 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
  117479. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  117480. * * 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
  117481. * * It must returns a float value that will be the scale value applied to the shape on each path point
  117482. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  117483. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  117484. * * 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
  117485. * * 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
  117486. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  117487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117488. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117489. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117491. * @param name defines the name of the mesh
  117492. * @param options defines the options used to create the mesh
  117493. * @param scene defines the hosting scene
  117494. * @returns the custom extruded shape mesh
  117495. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  117496. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117497. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117498. */
  117499. static ExtrudeShapeCustom(name: string, options: {
  117500. shape: Vector3[];
  117501. path: Vector3[];
  117502. scaleFunction?: any;
  117503. rotationFunction?: any;
  117504. ribbonCloseArray?: boolean;
  117505. ribbonClosePath?: boolean;
  117506. cap?: number;
  117507. updatable?: boolean;
  117508. sideOrientation?: number;
  117509. frontUVs?: Vector4;
  117510. backUVs?: Vector4;
  117511. instance?: Mesh;
  117512. invertUV?: boolean;
  117513. }, scene?: Nullable<Scene>): Mesh;
  117514. private static _ExtrudeShapeGeneric;
  117515. }
  117516. }
  117517. declare module BABYLON {
  117518. /**
  117519. * AmmoJS Physics plugin
  117520. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117521. * @see https://github.com/kripken/ammo.js/
  117522. */
  117523. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  117524. private _useDeltaForWorldStep;
  117525. /**
  117526. * Reference to the Ammo library
  117527. */
  117528. bjsAMMO: any;
  117529. /**
  117530. * Created ammoJS world which physics bodies are added to
  117531. */
  117532. world: any;
  117533. /**
  117534. * Name of the plugin
  117535. */
  117536. name: string;
  117537. private _timeStep;
  117538. private _fixedTimeStep;
  117539. private _maxSteps;
  117540. private _tmpQuaternion;
  117541. private _tmpAmmoTransform;
  117542. private _tmpAmmoQuaternion;
  117543. private _tmpAmmoConcreteContactResultCallback;
  117544. private _collisionConfiguration;
  117545. private _dispatcher;
  117546. private _overlappingPairCache;
  117547. private _solver;
  117548. private _softBodySolver;
  117549. private _tmpAmmoVectorA;
  117550. private _tmpAmmoVectorB;
  117551. private _tmpAmmoVectorC;
  117552. private _tmpAmmoVectorD;
  117553. private _tmpContactCallbackResult;
  117554. private _tmpAmmoVectorRCA;
  117555. private _tmpAmmoVectorRCB;
  117556. private _raycastResult;
  117557. private static readonly DISABLE_COLLISION_FLAG;
  117558. private static readonly KINEMATIC_FLAG;
  117559. private static readonly DISABLE_DEACTIVATION_FLAG;
  117560. /**
  117561. * Initializes the ammoJS plugin
  117562. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  117563. * @param ammoInjection can be used to inject your own ammo reference
  117564. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  117565. */
  117566. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  117567. /**
  117568. * Sets the gravity of the physics world (m/(s^2))
  117569. * @param gravity Gravity to set
  117570. */
  117571. setGravity(gravity: Vector3): void;
  117572. /**
  117573. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  117574. * @param timeStep timestep to use in seconds
  117575. */
  117576. setTimeStep(timeStep: number): void;
  117577. /**
  117578. * 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)
  117579. * @param fixedTimeStep fixedTimeStep to use in seconds
  117580. */
  117581. setFixedTimeStep(fixedTimeStep: number): void;
  117582. /**
  117583. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  117584. * @param maxSteps the maximum number of steps by the physics engine per frame
  117585. */
  117586. setMaxSteps(maxSteps: number): void;
  117587. /**
  117588. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  117589. * @returns the current timestep in seconds
  117590. */
  117591. getTimeStep(): number;
  117592. private _isImpostorInContact;
  117593. private _isImpostorPairInContact;
  117594. private _stepSimulation;
  117595. /**
  117596. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  117597. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  117598. * After the step the babylon meshes are set to the position of the physics imposters
  117599. * @param delta amount of time to step forward
  117600. * @param impostors array of imposters to update before/after the step
  117601. */
  117602. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117603. /**
  117604. * Update babylon mesh to match physics world object
  117605. * @param impostor imposter to match
  117606. */
  117607. private _afterSoftStep;
  117608. /**
  117609. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  117610. * @param impostor imposter to match
  117611. */
  117612. private _ropeStep;
  117613. /**
  117614. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  117615. * @param impostor imposter to match
  117616. */
  117617. private _softbodyOrClothStep;
  117618. private _tmpVector;
  117619. private _tmpMatrix;
  117620. /**
  117621. * Applies an impulse on the imposter
  117622. * @param impostor imposter to apply impulse to
  117623. * @param force amount of force to be applied to the imposter
  117624. * @param contactPoint the location to apply the impulse on the imposter
  117625. */
  117626. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117627. /**
  117628. * Applies a force on the imposter
  117629. * @param impostor imposter to apply force
  117630. * @param force amount of force to be applied to the imposter
  117631. * @param contactPoint the location to apply the force on the imposter
  117632. */
  117633. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117634. /**
  117635. * Creates a physics body using the plugin
  117636. * @param impostor the imposter to create the physics body on
  117637. */
  117638. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117639. /**
  117640. * Removes the physics body from the imposter and disposes of the body's memory
  117641. * @param impostor imposter to remove the physics body from
  117642. */
  117643. removePhysicsBody(impostor: PhysicsImpostor): void;
  117644. /**
  117645. * Generates a joint
  117646. * @param impostorJoint the imposter joint to create the joint with
  117647. */
  117648. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117649. /**
  117650. * Removes a joint
  117651. * @param impostorJoint the imposter joint to remove the joint from
  117652. */
  117653. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117654. private _addMeshVerts;
  117655. /**
  117656. * Initialise the soft body vertices to match its object's (mesh) vertices
  117657. * Softbody vertices (nodes) are in world space and to match this
  117658. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  117659. * @param impostor to create the softbody for
  117660. */
  117661. private _softVertexData;
  117662. /**
  117663. * Create an impostor's soft body
  117664. * @param impostor to create the softbody for
  117665. */
  117666. private _createSoftbody;
  117667. /**
  117668. * Create cloth for an impostor
  117669. * @param impostor to create the softbody for
  117670. */
  117671. private _createCloth;
  117672. /**
  117673. * Create rope for an impostor
  117674. * @param impostor to create the softbody for
  117675. */
  117676. private _createRope;
  117677. private _addHullVerts;
  117678. private _createShape;
  117679. /**
  117680. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  117681. * @param impostor imposter containing the physics body and babylon object
  117682. */
  117683. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117684. /**
  117685. * Sets the babylon object's position/rotation from the physics body's position/rotation
  117686. * @param impostor imposter containing the physics body and babylon object
  117687. * @param newPosition new position
  117688. * @param newRotation new rotation
  117689. */
  117690. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117691. /**
  117692. * If this plugin is supported
  117693. * @returns true if its supported
  117694. */
  117695. isSupported(): boolean;
  117696. /**
  117697. * Sets the linear velocity of the physics body
  117698. * @param impostor imposter to set the velocity on
  117699. * @param velocity velocity to set
  117700. */
  117701. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117702. /**
  117703. * Sets the angular velocity of the physics body
  117704. * @param impostor imposter to set the velocity on
  117705. * @param velocity velocity to set
  117706. */
  117707. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117708. /**
  117709. * gets the linear velocity
  117710. * @param impostor imposter to get linear velocity from
  117711. * @returns linear velocity
  117712. */
  117713. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117714. /**
  117715. * gets the angular velocity
  117716. * @param impostor imposter to get angular velocity from
  117717. * @returns angular velocity
  117718. */
  117719. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117720. /**
  117721. * Sets the mass of physics body
  117722. * @param impostor imposter to set the mass on
  117723. * @param mass mass to set
  117724. */
  117725. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117726. /**
  117727. * Gets the mass of the physics body
  117728. * @param impostor imposter to get the mass from
  117729. * @returns mass
  117730. */
  117731. getBodyMass(impostor: PhysicsImpostor): number;
  117732. /**
  117733. * Gets friction of the impostor
  117734. * @param impostor impostor to get friction from
  117735. * @returns friction value
  117736. */
  117737. getBodyFriction(impostor: PhysicsImpostor): number;
  117738. /**
  117739. * Sets friction of the impostor
  117740. * @param impostor impostor to set friction on
  117741. * @param friction friction value
  117742. */
  117743. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117744. /**
  117745. * Gets restitution of the impostor
  117746. * @param impostor impostor to get restitution from
  117747. * @returns restitution value
  117748. */
  117749. getBodyRestitution(impostor: PhysicsImpostor): number;
  117750. /**
  117751. * Sets resitution of the impostor
  117752. * @param impostor impostor to set resitution on
  117753. * @param restitution resitution value
  117754. */
  117755. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117756. /**
  117757. * Gets pressure inside the impostor
  117758. * @param impostor impostor to get pressure from
  117759. * @returns pressure value
  117760. */
  117761. getBodyPressure(impostor: PhysicsImpostor): number;
  117762. /**
  117763. * Sets pressure inside a soft body impostor
  117764. * Cloth and rope must remain 0 pressure
  117765. * @param impostor impostor to set pressure on
  117766. * @param pressure pressure value
  117767. */
  117768. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  117769. /**
  117770. * Gets stiffness of the impostor
  117771. * @param impostor impostor to get stiffness from
  117772. * @returns pressure value
  117773. */
  117774. getBodyStiffness(impostor: PhysicsImpostor): number;
  117775. /**
  117776. * Sets stiffness of the impostor
  117777. * @param impostor impostor to set stiffness on
  117778. * @param stiffness stiffness value from 0 to 1
  117779. */
  117780. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  117781. /**
  117782. * Gets velocityIterations of the impostor
  117783. * @param impostor impostor to get velocity iterations from
  117784. * @returns velocityIterations value
  117785. */
  117786. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  117787. /**
  117788. * Sets velocityIterations of the impostor
  117789. * @param impostor impostor to set velocity iterations on
  117790. * @param velocityIterations velocityIterations value
  117791. */
  117792. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  117793. /**
  117794. * Gets positionIterations of the impostor
  117795. * @param impostor impostor to get position iterations from
  117796. * @returns positionIterations value
  117797. */
  117798. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  117799. /**
  117800. * Sets positionIterations of the impostor
  117801. * @param impostor impostor to set position on
  117802. * @param positionIterations positionIterations value
  117803. */
  117804. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  117805. /**
  117806. * Append an anchor to a cloth object
  117807. * @param impostor is the cloth impostor to add anchor to
  117808. * @param otherImpostor is the rigid impostor to anchor to
  117809. * @param width ratio across width from 0 to 1
  117810. * @param height ratio up height from 0 to 1
  117811. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  117812. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  117813. */
  117814. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  117815. /**
  117816. * Append an hook to a rope object
  117817. * @param impostor is the rope impostor to add hook to
  117818. * @param otherImpostor is the rigid impostor to hook to
  117819. * @param length ratio along the rope from 0 to 1
  117820. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  117821. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  117822. */
  117823. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  117824. /**
  117825. * Sleeps the physics body and stops it from being active
  117826. * @param impostor impostor to sleep
  117827. */
  117828. sleepBody(impostor: PhysicsImpostor): void;
  117829. /**
  117830. * Activates the physics body
  117831. * @param impostor impostor to activate
  117832. */
  117833. wakeUpBody(impostor: PhysicsImpostor): void;
  117834. /**
  117835. * Updates the distance parameters of the joint
  117836. * @param joint joint to update
  117837. * @param maxDistance maximum distance of the joint
  117838. * @param minDistance minimum distance of the joint
  117839. */
  117840. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  117841. /**
  117842. * Sets a motor on the joint
  117843. * @param joint joint to set motor on
  117844. * @param speed speed of the motor
  117845. * @param maxForce maximum force of the motor
  117846. * @param motorIndex index of the motor
  117847. */
  117848. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  117849. /**
  117850. * Sets the motors limit
  117851. * @param joint joint to set limit on
  117852. * @param upperLimit upper limit
  117853. * @param lowerLimit lower limit
  117854. */
  117855. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  117856. /**
  117857. * Syncs the position and rotation of a mesh with the impostor
  117858. * @param mesh mesh to sync
  117859. * @param impostor impostor to update the mesh with
  117860. */
  117861. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117862. /**
  117863. * Gets the radius of the impostor
  117864. * @param impostor impostor to get radius from
  117865. * @returns the radius
  117866. */
  117867. getRadius(impostor: PhysicsImpostor): number;
  117868. /**
  117869. * Gets the box size of the impostor
  117870. * @param impostor impostor to get box size from
  117871. * @param result the resulting box size
  117872. */
  117873. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117874. /**
  117875. * Disposes of the impostor
  117876. */
  117877. dispose(): void;
  117878. /**
  117879. * Does a raycast in the physics world
  117880. * @param from when should the ray start?
  117881. * @param to when should the ray end?
  117882. * @returns PhysicsRaycastResult
  117883. */
  117884. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117885. }
  117886. }
  117887. declare module BABYLON {
  117888. interface AbstractScene {
  117889. /**
  117890. * The list of reflection probes added to the scene
  117891. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  117892. */
  117893. reflectionProbes: Array<ReflectionProbe>;
  117894. /**
  117895. * Removes the given reflection probe from this scene.
  117896. * @param toRemove The reflection probe to remove
  117897. * @returns The index of the removed reflection probe
  117898. */
  117899. removeReflectionProbe(toRemove: ReflectionProbe): number;
  117900. /**
  117901. * Adds the given reflection probe to this scene.
  117902. * @param newReflectionProbe The reflection probe to add
  117903. */
  117904. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  117905. }
  117906. /**
  117907. * Class used to generate realtime reflection / refraction cube textures
  117908. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  117909. */
  117910. export class ReflectionProbe {
  117911. /** defines the name of the probe */
  117912. name: string;
  117913. private _scene;
  117914. private _renderTargetTexture;
  117915. private _projectionMatrix;
  117916. private _viewMatrix;
  117917. private _target;
  117918. private _add;
  117919. private _attachedMesh;
  117920. private _invertYAxis;
  117921. /** Gets or sets probe position (center of the cube map) */
  117922. position: Vector3;
  117923. /**
  117924. * Creates a new reflection probe
  117925. * @param name defines the name of the probe
  117926. * @param size defines the texture resolution (for each face)
  117927. * @param scene defines the hosting scene
  117928. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  117929. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  117930. */
  117931. constructor(
  117932. /** defines the name of the probe */
  117933. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  117934. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  117935. samples: number;
  117936. /** Gets or sets the refresh rate to use (on every frame by default) */
  117937. refreshRate: number;
  117938. /**
  117939. * Gets the hosting scene
  117940. * @returns a Scene
  117941. */
  117942. getScene(): Scene;
  117943. /** Gets the internal CubeTexture used to render to */
  117944. readonly cubeTexture: RenderTargetTexture;
  117945. /** Gets the list of meshes to render */
  117946. readonly renderList: Nullable<AbstractMesh[]>;
  117947. /**
  117948. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  117949. * @param mesh defines the mesh to attach to
  117950. */
  117951. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  117952. /**
  117953. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  117954. * @param renderingGroupId The rendering group id corresponding to its index
  117955. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  117956. */
  117957. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  117958. /**
  117959. * Clean all associated resources
  117960. */
  117961. dispose(): void;
  117962. /**
  117963. * Converts the reflection probe information to a readable string for debug purpose.
  117964. * @param fullDetails Supports for multiple levels of logging within scene loading
  117965. * @returns the human readable reflection probe info
  117966. */
  117967. toString(fullDetails?: boolean): string;
  117968. /**
  117969. * Get the class name of the relfection probe.
  117970. * @returns "ReflectionProbe"
  117971. */
  117972. getClassName(): string;
  117973. /**
  117974. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  117975. * @returns The JSON representation of the texture
  117976. */
  117977. serialize(): any;
  117978. /**
  117979. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  117980. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  117981. * @param scene Define the scene the parsed reflection probe should be instantiated in
  117982. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  117983. * @returns The parsed reflection probe if successful
  117984. */
  117985. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  117986. }
  117987. }
  117988. declare module BABYLON {
  117989. /** @hidden */
  117990. export var _BabylonLoaderRegistered: boolean;
  117991. }
  117992. declare module BABYLON {
  117993. /**
  117994. * The Physically based simple base material of BJS.
  117995. *
  117996. * This enables better naming and convention enforcements on top of the pbrMaterial.
  117997. * It is used as the base class for both the specGloss and metalRough conventions.
  117998. */
  117999. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  118000. /**
  118001. * Number of Simultaneous lights allowed on the material.
  118002. */
  118003. maxSimultaneousLights: number;
  118004. /**
  118005. * If sets to true, disables all the lights affecting the material.
  118006. */
  118007. disableLighting: boolean;
  118008. /**
  118009. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  118010. */
  118011. environmentTexture: BaseTexture;
  118012. /**
  118013. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  118014. */
  118015. invertNormalMapX: boolean;
  118016. /**
  118017. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  118018. */
  118019. invertNormalMapY: boolean;
  118020. /**
  118021. * Normal map used in the model.
  118022. */
  118023. normalTexture: BaseTexture;
  118024. /**
  118025. * Emissivie color used to self-illuminate the model.
  118026. */
  118027. emissiveColor: Color3;
  118028. /**
  118029. * Emissivie texture used to self-illuminate the model.
  118030. */
  118031. emissiveTexture: BaseTexture;
  118032. /**
  118033. * Occlusion Channel Strenght.
  118034. */
  118035. occlusionStrength: number;
  118036. /**
  118037. * Occlusion Texture of the material (adding extra occlusion effects).
  118038. */
  118039. occlusionTexture: BaseTexture;
  118040. /**
  118041. * Defines the alpha limits in alpha test mode.
  118042. */
  118043. alphaCutOff: number;
  118044. /**
  118045. * Gets the current double sided mode.
  118046. */
  118047. /**
  118048. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118049. */
  118050. doubleSided: boolean;
  118051. /**
  118052. * Stores the pre-calculated light information of a mesh in a texture.
  118053. */
  118054. lightmapTexture: BaseTexture;
  118055. /**
  118056. * If true, the light map contains occlusion information instead of lighting info.
  118057. */
  118058. useLightmapAsShadowmap: boolean;
  118059. /**
  118060. * Instantiates a new PBRMaterial instance.
  118061. *
  118062. * @param name The material name
  118063. * @param scene The scene the material will be use in.
  118064. */
  118065. constructor(name: string, scene: Scene);
  118066. getClassName(): string;
  118067. }
  118068. }
  118069. declare module BABYLON {
  118070. /**
  118071. * The PBR material of BJS following the metal roughness convention.
  118072. *
  118073. * This fits to the PBR convention in the GLTF definition:
  118074. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  118075. */
  118076. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  118077. /**
  118078. * The base color has two different interpretations depending on the value of metalness.
  118079. * When the material is a metal, the base color is the specific measured reflectance value
  118080. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  118081. * of the material.
  118082. */
  118083. baseColor: Color3;
  118084. /**
  118085. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  118086. * well as opacity information in the alpha channel.
  118087. */
  118088. baseTexture: BaseTexture;
  118089. /**
  118090. * Specifies the metallic scalar value of the material.
  118091. * Can also be used to scale the metalness values of the metallic texture.
  118092. */
  118093. metallic: number;
  118094. /**
  118095. * Specifies the roughness scalar value of the material.
  118096. * Can also be used to scale the roughness values of the metallic texture.
  118097. */
  118098. roughness: number;
  118099. /**
  118100. * Texture containing both the metallic value in the B channel and the
  118101. * roughness value in the G channel to keep better precision.
  118102. */
  118103. metallicRoughnessTexture: BaseTexture;
  118104. /**
  118105. * Instantiates a new PBRMetalRoughnessMaterial instance.
  118106. *
  118107. * @param name The material name
  118108. * @param scene The scene the material will be use in.
  118109. */
  118110. constructor(name: string, scene: Scene);
  118111. /**
  118112. * Return the currrent class name of the material.
  118113. */
  118114. getClassName(): string;
  118115. /**
  118116. * Makes a duplicate of the current material.
  118117. * @param name - name to use for the new material.
  118118. */
  118119. clone(name: string): PBRMetallicRoughnessMaterial;
  118120. /**
  118121. * Serialize the material to a parsable JSON object.
  118122. */
  118123. serialize(): any;
  118124. /**
  118125. * Parses a JSON object correponding to the serialize function.
  118126. */
  118127. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  118128. }
  118129. }
  118130. declare module BABYLON {
  118131. /**
  118132. * The PBR material of BJS following the specular glossiness convention.
  118133. *
  118134. * This fits to the PBR convention in the GLTF definition:
  118135. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  118136. */
  118137. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  118138. /**
  118139. * Specifies the diffuse color of the material.
  118140. */
  118141. diffuseColor: Color3;
  118142. /**
  118143. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  118144. * channel.
  118145. */
  118146. diffuseTexture: BaseTexture;
  118147. /**
  118148. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  118149. */
  118150. specularColor: Color3;
  118151. /**
  118152. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  118153. */
  118154. glossiness: number;
  118155. /**
  118156. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  118157. */
  118158. specularGlossinessTexture: BaseTexture;
  118159. /**
  118160. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  118161. *
  118162. * @param name The material name
  118163. * @param scene The scene the material will be use in.
  118164. */
  118165. constructor(name: string, scene: Scene);
  118166. /**
  118167. * Return the currrent class name of the material.
  118168. */
  118169. getClassName(): string;
  118170. /**
  118171. * Makes a duplicate of the current material.
  118172. * @param name - name to use for the new material.
  118173. */
  118174. clone(name: string): PBRSpecularGlossinessMaterial;
  118175. /**
  118176. * Serialize the material to a parsable JSON object.
  118177. */
  118178. serialize(): any;
  118179. /**
  118180. * Parses a JSON object correponding to the serialize function.
  118181. */
  118182. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  118183. }
  118184. }
  118185. declare module BABYLON {
  118186. /**
  118187. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  118188. * It can help converting any input color in a desired output one. This can then be used to create effects
  118189. * from sepia, black and white to sixties or futuristic rendering...
  118190. *
  118191. * The only supported format is currently 3dl.
  118192. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  118193. */
  118194. export class ColorGradingTexture extends BaseTexture {
  118195. /**
  118196. * The current texture matrix. (will always be identity in color grading texture)
  118197. */
  118198. private _textureMatrix;
  118199. /**
  118200. * The texture URL.
  118201. */
  118202. url: string;
  118203. /**
  118204. * Empty line regex stored for GC.
  118205. */
  118206. private static _noneEmptyLineRegex;
  118207. private _engine;
  118208. /**
  118209. * Instantiates a ColorGradingTexture from the following parameters.
  118210. *
  118211. * @param url The location of the color gradind data (currently only supporting 3dl)
  118212. * @param scene The scene the texture will be used in
  118213. */
  118214. constructor(url: string, scene: Scene);
  118215. /**
  118216. * Returns the texture matrix used in most of the material.
  118217. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  118218. */
  118219. getTextureMatrix(): Matrix;
  118220. /**
  118221. * Occurs when the file being loaded is a .3dl LUT file.
  118222. */
  118223. private load3dlTexture;
  118224. /**
  118225. * Starts the loading process of the texture.
  118226. */
  118227. private loadTexture;
  118228. /**
  118229. * Clones the color gradind texture.
  118230. */
  118231. clone(): ColorGradingTexture;
  118232. /**
  118233. * Called during delayed load for textures.
  118234. */
  118235. delayLoad(): void;
  118236. /**
  118237. * Parses a color grading texture serialized by Babylon.
  118238. * @param parsedTexture The texture information being parsedTexture
  118239. * @param scene The scene to load the texture in
  118240. * @param rootUrl The root url of the data assets to load
  118241. * @return A color gradind texture
  118242. */
  118243. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  118244. /**
  118245. * Serializes the LUT texture to json format.
  118246. */
  118247. serialize(): any;
  118248. }
  118249. }
  118250. declare module BABYLON {
  118251. /**
  118252. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  118253. */
  118254. export class EquiRectangularCubeTexture extends BaseTexture {
  118255. /** The six faces of the cube. */
  118256. private static _FacesMapping;
  118257. private _noMipmap;
  118258. private _onLoad;
  118259. private _onError;
  118260. /** The size of the cubemap. */
  118261. private _size;
  118262. /** The buffer of the image. */
  118263. private _buffer;
  118264. /** The width of the input image. */
  118265. private _width;
  118266. /** The height of the input image. */
  118267. private _height;
  118268. /** The URL to the image. */
  118269. url: string;
  118270. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  118271. coordinatesMode: number;
  118272. /**
  118273. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  118274. * @param url The location of the image
  118275. * @param scene The scene the texture will be used in
  118276. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118277. * @param noMipmap Forces to not generate the mipmap if true
  118278. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  118279. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  118280. * @param onLoad — defines a callback called when texture is loaded
  118281. * @param onError — defines a callback called if there is an error
  118282. */
  118283. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  118284. /**
  118285. * Load the image data, by putting the image on a canvas and extracting its buffer.
  118286. */
  118287. private loadImage;
  118288. /**
  118289. * Convert the image buffer into a cubemap and create a CubeTexture.
  118290. */
  118291. private loadTexture;
  118292. /**
  118293. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  118294. * @param buffer The ArrayBuffer that should be converted.
  118295. * @returns The buffer as Float32Array.
  118296. */
  118297. private getFloat32ArrayFromArrayBuffer;
  118298. /**
  118299. * Get the current class name of the texture useful for serialization or dynamic coding.
  118300. * @returns "EquiRectangularCubeTexture"
  118301. */
  118302. getClassName(): string;
  118303. /**
  118304. * Create a clone of the current EquiRectangularCubeTexture and return it.
  118305. * @returns A clone of the current EquiRectangularCubeTexture.
  118306. */
  118307. clone(): EquiRectangularCubeTexture;
  118308. }
  118309. }
  118310. declare module BABYLON {
  118311. /**
  118312. * Based on jsTGALoader - Javascript loader for TGA file
  118313. * By Vincent Thibault
  118314. * @see http://blog.robrowser.com/javascript-tga-loader.html
  118315. */
  118316. export class TGATools {
  118317. private static _TYPE_INDEXED;
  118318. private static _TYPE_RGB;
  118319. private static _TYPE_GREY;
  118320. private static _TYPE_RLE_INDEXED;
  118321. private static _TYPE_RLE_RGB;
  118322. private static _TYPE_RLE_GREY;
  118323. private static _ORIGIN_MASK;
  118324. private static _ORIGIN_SHIFT;
  118325. private static _ORIGIN_BL;
  118326. private static _ORIGIN_BR;
  118327. private static _ORIGIN_UL;
  118328. private static _ORIGIN_UR;
  118329. /**
  118330. * Gets the header of a TGA file
  118331. * @param data defines the TGA data
  118332. * @returns the header
  118333. */
  118334. static GetTGAHeader(data: Uint8Array): any;
  118335. /**
  118336. * Uploads TGA content to a Babylon Texture
  118337. * @hidden
  118338. */
  118339. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  118340. /** @hidden */
  118341. 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;
  118342. /** @hidden */
  118343. 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;
  118344. /** @hidden */
  118345. 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;
  118346. /** @hidden */
  118347. 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;
  118348. /** @hidden */
  118349. 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;
  118350. /** @hidden */
  118351. 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;
  118352. }
  118353. }
  118354. declare module BABYLON {
  118355. /**
  118356. * Implementation of the TGA Texture Loader.
  118357. * @hidden
  118358. */
  118359. export class _TGATextureLoader implements IInternalTextureLoader {
  118360. /**
  118361. * Defines wether the loader supports cascade loading the different faces.
  118362. */
  118363. readonly supportCascades: boolean;
  118364. /**
  118365. * This returns if the loader support the current file information.
  118366. * @param extension defines the file extension of the file being loaded
  118367. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118368. * @param fallback defines the fallback internal texture if any
  118369. * @param isBase64 defines whether the texture is encoded as a base64
  118370. * @param isBuffer defines whether the texture data are stored as a buffer
  118371. * @returns true if the loader can load the specified file
  118372. */
  118373. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118374. /**
  118375. * Transform the url before loading if required.
  118376. * @param rootUrl the url of the texture
  118377. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118378. * @returns the transformed texture
  118379. */
  118380. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118381. /**
  118382. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118383. * @param rootUrl the url of the texture
  118384. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118385. * @returns the fallback texture
  118386. */
  118387. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118388. /**
  118389. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118390. * @param data contains the texture data
  118391. * @param texture defines the BabylonJS internal texture
  118392. * @param createPolynomials will be true if polynomials have been requested
  118393. * @param onLoad defines the callback to trigger once the texture is ready
  118394. * @param onError defines the callback to trigger in case of error
  118395. */
  118396. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118397. /**
  118398. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118399. * @param data contains the texture data
  118400. * @param texture defines the BabylonJS internal texture
  118401. * @param callback defines the method to call once ready to upload
  118402. */
  118403. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118404. }
  118405. }
  118406. declare module BABYLON {
  118407. /**
  118408. * Info about the .basis files
  118409. */
  118410. class BasisFileInfo {
  118411. /**
  118412. * If the file has alpha
  118413. */
  118414. hasAlpha: boolean;
  118415. /**
  118416. * Info about each image of the basis file
  118417. */
  118418. images: Array<{
  118419. levels: Array<{
  118420. width: number;
  118421. height: number;
  118422. transcodedPixels: ArrayBufferView;
  118423. }>;
  118424. }>;
  118425. }
  118426. /**
  118427. * Result of transcoding a basis file
  118428. */
  118429. class TranscodeResult {
  118430. /**
  118431. * Info about the .basis file
  118432. */
  118433. fileInfo: BasisFileInfo;
  118434. /**
  118435. * Format to use when loading the file
  118436. */
  118437. format: number;
  118438. }
  118439. /**
  118440. * Configuration options for the Basis transcoder
  118441. */
  118442. export class BasisTranscodeConfiguration {
  118443. /**
  118444. * Supported compression formats used to determine the supported output format of the transcoder
  118445. */
  118446. supportedCompressionFormats?: {
  118447. /**
  118448. * etc1 compression format
  118449. */
  118450. etc1?: boolean;
  118451. /**
  118452. * s3tc compression format
  118453. */
  118454. s3tc?: boolean;
  118455. /**
  118456. * pvrtc compression format
  118457. */
  118458. pvrtc?: boolean;
  118459. /**
  118460. * etc2 compression format
  118461. */
  118462. etc2?: boolean;
  118463. };
  118464. /**
  118465. * If mipmap levels should be loaded for transcoded images (Default: true)
  118466. */
  118467. loadMipmapLevels?: boolean;
  118468. /**
  118469. * Index of a single image to load (Default: all images)
  118470. */
  118471. loadSingleImage?: number;
  118472. }
  118473. /**
  118474. * Used to load .Basis files
  118475. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  118476. */
  118477. export class BasisTools {
  118478. private static _IgnoreSupportedFormats;
  118479. /**
  118480. * URL to use when loading the basis transcoder
  118481. */
  118482. static JSModuleURL: string;
  118483. /**
  118484. * URL to use when loading the wasm module for the transcoder
  118485. */
  118486. static WasmModuleURL: string;
  118487. /**
  118488. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  118489. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  118490. * @returns internal format corresponding to the Basis format
  118491. */
  118492. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  118493. private static _WorkerPromise;
  118494. private static _Worker;
  118495. private static _actionId;
  118496. private static _CreateWorkerAsync;
  118497. /**
  118498. * Transcodes a loaded image file to compressed pixel data
  118499. * @param imageData image data to transcode
  118500. * @param config configuration options for the transcoding
  118501. * @returns a promise resulting in the transcoded image
  118502. */
  118503. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  118504. /**
  118505. * Loads a texture from the transcode result
  118506. * @param texture texture load to
  118507. * @param transcodeResult the result of transcoding the basis file to load from
  118508. */
  118509. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  118510. }
  118511. }
  118512. declare module BABYLON {
  118513. /**
  118514. * Loader for .basis file format
  118515. */
  118516. export class _BasisTextureLoader implements IInternalTextureLoader {
  118517. /**
  118518. * Defines whether the loader supports cascade loading the different faces.
  118519. */
  118520. readonly supportCascades: boolean;
  118521. /**
  118522. * This returns if the loader support the current file information.
  118523. * @param extension defines the file extension of the file being loaded
  118524. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118525. * @param fallback defines the fallback internal texture if any
  118526. * @param isBase64 defines whether the texture is encoded as a base64
  118527. * @param isBuffer defines whether the texture data are stored as a buffer
  118528. * @returns true if the loader can load the specified file
  118529. */
  118530. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118531. /**
  118532. * Transform the url before loading if required.
  118533. * @param rootUrl the url of the texture
  118534. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118535. * @returns the transformed texture
  118536. */
  118537. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118538. /**
  118539. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118540. * @param rootUrl the url of the texture
  118541. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118542. * @returns the fallback texture
  118543. */
  118544. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118545. /**
  118546. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  118547. * @param data contains the texture data
  118548. * @param texture defines the BabylonJS internal texture
  118549. * @param createPolynomials will be true if polynomials have been requested
  118550. * @param onLoad defines the callback to trigger once the texture is ready
  118551. * @param onError defines the callback to trigger in case of error
  118552. */
  118553. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118554. /**
  118555. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118556. * @param data contains the texture data
  118557. * @param texture defines the BabylonJS internal texture
  118558. * @param callback defines the method to call once ready to upload
  118559. */
  118560. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118561. }
  118562. }
  118563. declare module BABYLON {
  118564. /**
  118565. * 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.
  118566. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  118567. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  118568. */
  118569. export class CustomProceduralTexture extends ProceduralTexture {
  118570. private _animate;
  118571. private _time;
  118572. private _config;
  118573. private _texturePath;
  118574. /**
  118575. * Instantiates a new Custom Procedural Texture.
  118576. * 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.
  118577. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  118578. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  118579. * @param name Define the name of the texture
  118580. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  118581. * @param size Define the size of the texture to create
  118582. * @param scene Define the scene the texture belongs to
  118583. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  118584. * @param generateMipMaps Define if the texture should creates mip maps or not
  118585. */
  118586. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  118587. private _loadJson;
  118588. /**
  118589. * Is the texture ready to be used ? (rendered at least once)
  118590. * @returns true if ready, otherwise, false.
  118591. */
  118592. isReady(): boolean;
  118593. /**
  118594. * Render the texture to its associated render target.
  118595. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  118596. */
  118597. render(useCameraPostProcess?: boolean): void;
  118598. /**
  118599. * Update the list of dependant textures samplers in the shader.
  118600. */
  118601. updateTextures(): void;
  118602. /**
  118603. * Update the uniform values of the procedural texture in the shader.
  118604. */
  118605. updateShaderUniforms(): void;
  118606. /**
  118607. * Define if the texture animates or not.
  118608. */
  118609. animate: boolean;
  118610. }
  118611. }
  118612. declare module BABYLON {
  118613. /** @hidden */
  118614. export var noisePixelShader: {
  118615. name: string;
  118616. shader: string;
  118617. };
  118618. }
  118619. declare module BABYLON {
  118620. /**
  118621. * Class used to generate noise procedural textures
  118622. */
  118623. export class NoiseProceduralTexture extends ProceduralTexture {
  118624. private _time;
  118625. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  118626. brightness: number;
  118627. /** Defines the number of octaves to process */
  118628. octaves: number;
  118629. /** Defines the level of persistence (0.8 by default) */
  118630. persistence: number;
  118631. /** Gets or sets animation speed factor (default is 1) */
  118632. animationSpeedFactor: number;
  118633. /**
  118634. * Creates a new NoiseProceduralTexture
  118635. * @param name defines the name fo the texture
  118636. * @param size defines the size of the texture (default is 256)
  118637. * @param scene defines the hosting scene
  118638. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  118639. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  118640. */
  118641. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  118642. private _updateShaderUniforms;
  118643. protected _getDefines(): string;
  118644. /** Generate the current state of the procedural texture */
  118645. render(useCameraPostProcess?: boolean): void;
  118646. /**
  118647. * Serializes this noise procedural texture
  118648. * @returns a serialized noise procedural texture object
  118649. */
  118650. serialize(): any;
  118651. /**
  118652. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  118653. * @param parsedTexture defines parsed texture data
  118654. * @param scene defines the current scene
  118655. * @param rootUrl defines the root URL containing noise procedural texture information
  118656. * @returns a parsed NoiseProceduralTexture
  118657. */
  118658. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  118659. }
  118660. }
  118661. declare module BABYLON {
  118662. /**
  118663. * Raw cube texture where the raw buffers are passed in
  118664. */
  118665. export class RawCubeTexture extends CubeTexture {
  118666. /**
  118667. * Creates a cube texture where the raw buffers are passed in.
  118668. * @param scene defines the scene the texture is attached to
  118669. * @param data defines the array of data to use to create each face
  118670. * @param size defines the size of the textures
  118671. * @param format defines the format of the data
  118672. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  118673. * @param generateMipMaps defines if the engine should generate the mip levels
  118674. * @param invertY defines if data must be stored with Y axis inverted
  118675. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  118676. * @param compression defines the compression used (null by default)
  118677. */
  118678. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  118679. /**
  118680. * Updates the raw cube texture.
  118681. * @param data defines the data to store
  118682. * @param format defines the data format
  118683. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  118684. * @param invertY defines if data must be stored with Y axis inverted
  118685. * @param compression defines the compression used (null by default)
  118686. * @param level defines which level of the texture to update
  118687. */
  118688. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  118689. /**
  118690. * Updates a raw cube texture with RGBD encoded data.
  118691. * @param data defines the array of data [mipmap][face] to use to create each face
  118692. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  118693. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  118694. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  118695. * @returns a promsie that resolves when the operation is complete
  118696. */
  118697. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  118698. /**
  118699. * Clones the raw cube texture.
  118700. * @return a new cube texture
  118701. */
  118702. clone(): CubeTexture;
  118703. /** @hidden */
  118704. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  118705. }
  118706. }
  118707. declare module BABYLON {
  118708. /**
  118709. * Class used to store 3D textures containing user data
  118710. */
  118711. export class RawTexture3D extends Texture {
  118712. /** Gets or sets the texture format to use */
  118713. format: number;
  118714. private _engine;
  118715. /**
  118716. * Create a new RawTexture3D
  118717. * @param data defines the data of the texture
  118718. * @param width defines the width of the texture
  118719. * @param height defines the height of the texture
  118720. * @param depth defines the depth of the texture
  118721. * @param format defines the texture format to use
  118722. * @param scene defines the hosting scene
  118723. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  118724. * @param invertY defines if texture must be stored with Y axis inverted
  118725. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  118726. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  118727. */
  118728. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  118729. /** Gets or sets the texture format to use */
  118730. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  118731. /**
  118732. * Update the texture with new data
  118733. * @param data defines the data to store in the texture
  118734. */
  118735. update(data: ArrayBufferView): void;
  118736. }
  118737. }
  118738. declare module BABYLON {
  118739. /**
  118740. * Creates a refraction texture used by refraction channel of the standard material.
  118741. * It is like a mirror but to see through a material.
  118742. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  118743. */
  118744. export class RefractionTexture extends RenderTargetTexture {
  118745. /**
  118746. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  118747. * 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.
  118748. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  118749. */
  118750. refractionPlane: Plane;
  118751. /**
  118752. * Define how deep under the surface we should see.
  118753. */
  118754. depth: number;
  118755. /**
  118756. * Creates a refraction texture used by refraction channel of the standard material.
  118757. * It is like a mirror but to see through a material.
  118758. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  118759. * @param name Define the texture name
  118760. * @param size Define the size of the underlying texture
  118761. * @param scene Define the scene the refraction belongs to
  118762. * @param generateMipMaps Define if we need to generate mips level for the refraction
  118763. */
  118764. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  118765. /**
  118766. * Clone the refraction texture.
  118767. * @returns the cloned texture
  118768. */
  118769. clone(): RefractionTexture;
  118770. /**
  118771. * Serialize the texture to a JSON representation you could use in Parse later on
  118772. * @returns the serialized JSON representation
  118773. */
  118774. serialize(): any;
  118775. }
  118776. }
  118777. declare module BABYLON {
  118778. /**
  118779. * Defines the options related to the creation of an HtmlElementTexture
  118780. */
  118781. export interface IHtmlElementTextureOptions {
  118782. /**
  118783. * Defines wether mip maps should be created or not.
  118784. */
  118785. generateMipMaps?: boolean;
  118786. /**
  118787. * Defines the sampling mode of the texture.
  118788. */
  118789. samplingMode?: number;
  118790. /**
  118791. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  118792. */
  118793. engine: Nullable<Engine>;
  118794. /**
  118795. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  118796. */
  118797. scene: Nullable<Scene>;
  118798. }
  118799. /**
  118800. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  118801. * To be as efficient as possible depending on your constraints nothing aside the first upload
  118802. * is automatically managed.
  118803. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  118804. * in your application.
  118805. *
  118806. * As the update is not automatic, you need to call them manually.
  118807. */
  118808. export class HtmlElementTexture extends BaseTexture {
  118809. /**
  118810. * The texture URL.
  118811. */
  118812. element: HTMLVideoElement | HTMLCanvasElement;
  118813. private static readonly DefaultOptions;
  118814. private _textureMatrix;
  118815. private _engine;
  118816. private _isVideo;
  118817. private _generateMipMaps;
  118818. private _samplingMode;
  118819. /**
  118820. * Instantiates a HtmlElementTexture from the following parameters.
  118821. *
  118822. * @param name Defines the name of the texture
  118823. * @param element Defines the video or canvas the texture is filled with
  118824. * @param options Defines the other none mandatory texture creation options
  118825. */
  118826. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  118827. private _createInternalTexture;
  118828. /**
  118829. * Returns the texture matrix used in most of the material.
  118830. */
  118831. getTextureMatrix(): Matrix;
  118832. /**
  118833. * Updates the content of the texture.
  118834. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  118835. */
  118836. update(invertY?: Nullable<boolean>): void;
  118837. }
  118838. }
  118839. declare module BABYLON {
  118840. /**
  118841. * Enum used to define the target of a block
  118842. */
  118843. export enum NodeMaterialBlockTargets {
  118844. /** Vertex shader */
  118845. Vertex = 1,
  118846. /** Fragment shader */
  118847. Fragment = 2,
  118848. /** Neutral */
  118849. Neutral = 4,
  118850. /** Vertex and Fragment */
  118851. VertexAndFragment = 3
  118852. }
  118853. }
  118854. declare module BABYLON {
  118855. /**
  118856. * Defines the kind of connection point for node based material
  118857. */
  118858. export enum NodeMaterialBlockConnectionPointTypes {
  118859. /** Float */
  118860. Float = 1,
  118861. /** Int */
  118862. Int = 2,
  118863. /** Vector2 */
  118864. Vector2 = 4,
  118865. /** Vector3 */
  118866. Vector3 = 8,
  118867. /** Vector4 */
  118868. Vector4 = 16,
  118869. /** Color3 */
  118870. Color3 = 32,
  118871. /** Color4 */
  118872. Color4 = 64,
  118873. /** Matrix */
  118874. Matrix = 128,
  118875. /** Detect type based on connection */
  118876. AutoDetect = 1024,
  118877. /** Output type that will be defined by input type */
  118878. BasedOnInput = 2048
  118879. }
  118880. }
  118881. declare module BABYLON {
  118882. /**
  118883. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  118884. */
  118885. export enum NodeMaterialBlockConnectionPointMode {
  118886. /** Value is an uniform */
  118887. Uniform = 0,
  118888. /** Value is a mesh attribute */
  118889. Attribute = 1,
  118890. /** Value is a varying between vertex and fragment shaders */
  118891. Varying = 2,
  118892. /** Mode is undefined */
  118893. Undefined = 3
  118894. }
  118895. }
  118896. declare module BABYLON {
  118897. /**
  118898. * Enum used to define system values e.g. values automatically provided by the system
  118899. */
  118900. export enum NodeMaterialSystemValues {
  118901. /** World */
  118902. World = 1,
  118903. /** View */
  118904. View = 2,
  118905. /** Projection */
  118906. Projection = 3,
  118907. /** ViewProjection */
  118908. ViewProjection = 4,
  118909. /** WorldView */
  118910. WorldView = 5,
  118911. /** WorldViewProjection */
  118912. WorldViewProjection = 6,
  118913. /** CameraPosition */
  118914. CameraPosition = 7,
  118915. /** Fog Color */
  118916. FogColor = 8
  118917. }
  118918. }
  118919. declare module BABYLON {
  118920. /**
  118921. * Root class for all node material optimizers
  118922. */
  118923. export class NodeMaterialOptimizer {
  118924. /**
  118925. * Function used to optimize a NodeMaterial graph
  118926. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  118927. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  118928. */
  118929. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  118930. }
  118931. }
  118932. declare module BABYLON {
  118933. /**
  118934. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  118935. */
  118936. export class TransformBlock extends NodeMaterialBlock {
  118937. /**
  118938. * Defines the value to use to complement W value to transform it to a Vector4
  118939. */
  118940. complementW: number;
  118941. /**
  118942. * Defines the value to use to complement z value to transform it to a Vector4
  118943. */
  118944. complementZ: number;
  118945. /**
  118946. * Creates a new TransformBlock
  118947. * @param name defines the block name
  118948. */
  118949. constructor(name: string);
  118950. /**
  118951. * Gets the current class name
  118952. * @returns the class name
  118953. */
  118954. getClassName(): string;
  118955. /**
  118956. * Gets the vector input
  118957. */
  118958. readonly vector: NodeMaterialConnectionPoint;
  118959. /**
  118960. * Gets the output component
  118961. */
  118962. readonly output: NodeMaterialConnectionPoint;
  118963. /**
  118964. * Gets the matrix transform input
  118965. */
  118966. readonly transform: NodeMaterialConnectionPoint;
  118967. protected _buildBlock(state: NodeMaterialBuildState): this;
  118968. serialize(): any;
  118969. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118970. protected _dumpPropertiesCode(): string;
  118971. }
  118972. }
  118973. declare module BABYLON {
  118974. /**
  118975. * Block used to output the vertex position
  118976. */
  118977. export class VertexOutputBlock extends NodeMaterialBlock {
  118978. /**
  118979. * Creates a new VertexOutputBlock
  118980. * @param name defines the block name
  118981. */
  118982. constructor(name: string);
  118983. /**
  118984. * Gets the current class name
  118985. * @returns the class name
  118986. */
  118987. getClassName(): string;
  118988. /**
  118989. * Gets the vector input component
  118990. */
  118991. readonly vector: NodeMaterialConnectionPoint;
  118992. protected _buildBlock(state: NodeMaterialBuildState): this;
  118993. }
  118994. }
  118995. declare module BABYLON {
  118996. /**
  118997. * Block used to output the final color
  118998. */
  118999. export class FragmentOutputBlock extends NodeMaterialBlock {
  119000. /**
  119001. * Create a new FragmentOutputBlock
  119002. * @param name defines the block name
  119003. */
  119004. constructor(name: string);
  119005. /**
  119006. * Gets the current class name
  119007. * @returns the class name
  119008. */
  119009. getClassName(): string;
  119010. /**
  119011. * Gets the rgba input component
  119012. */
  119013. readonly rgba: NodeMaterialConnectionPoint;
  119014. /**
  119015. * Gets the rgb input component
  119016. */
  119017. readonly rgb: NodeMaterialConnectionPoint;
  119018. /**
  119019. * Gets the a input component
  119020. */
  119021. readonly a: NodeMaterialConnectionPoint;
  119022. protected _buildBlock(state: NodeMaterialBuildState): this;
  119023. }
  119024. }
  119025. declare module BABYLON {
  119026. /**
  119027. * Block used to read a reflection texture from a sampler
  119028. */
  119029. export class ReflectionTextureBlock extends NodeMaterialBlock {
  119030. private _define3DName;
  119031. private _defineCubicName;
  119032. private _defineExplicitName;
  119033. private _defineProjectionName;
  119034. private _defineLocalCubicName;
  119035. private _defineSphericalName;
  119036. private _definePlanarName;
  119037. private _defineEquirectangularName;
  119038. private _defineMirroredEquirectangularFixedName;
  119039. private _defineEquirectangularFixedName;
  119040. private _defineSkyboxName;
  119041. private _cubeSamplerName;
  119042. private _2DSamplerName;
  119043. private _positionUVWName;
  119044. private _directionWName;
  119045. private _reflectionCoordsName;
  119046. private _reflection2DCoordsName;
  119047. private _reflectionColorName;
  119048. private _reflectionMatrixName;
  119049. /**
  119050. * Gets or sets the texture associated with the node
  119051. */
  119052. texture: Nullable<BaseTexture>;
  119053. /**
  119054. * Create a new TextureBlock
  119055. * @param name defines the block name
  119056. */
  119057. constructor(name: string);
  119058. /**
  119059. * Gets the current class name
  119060. * @returns the class name
  119061. */
  119062. getClassName(): string;
  119063. /**
  119064. * Gets the world position input component
  119065. */
  119066. readonly position: NodeMaterialConnectionPoint;
  119067. /**
  119068. * Gets the world position input component
  119069. */
  119070. readonly worldPosition: NodeMaterialConnectionPoint;
  119071. /**
  119072. * Gets the world normal input component
  119073. */
  119074. readonly worldNormal: NodeMaterialConnectionPoint;
  119075. /**
  119076. * Gets the world input component
  119077. */
  119078. readonly world: NodeMaterialConnectionPoint;
  119079. /**
  119080. * Gets the camera (or eye) position component
  119081. */
  119082. readonly cameraPosition: NodeMaterialConnectionPoint;
  119083. /**
  119084. * Gets the view input component
  119085. */
  119086. readonly view: NodeMaterialConnectionPoint;
  119087. /**
  119088. * Gets the rgb output component
  119089. */
  119090. readonly rgb: NodeMaterialConnectionPoint;
  119091. /**
  119092. * Gets the r output component
  119093. */
  119094. readonly r: NodeMaterialConnectionPoint;
  119095. /**
  119096. * Gets the g output component
  119097. */
  119098. readonly g: NodeMaterialConnectionPoint;
  119099. /**
  119100. * Gets the b output component
  119101. */
  119102. readonly b: NodeMaterialConnectionPoint;
  119103. autoConfigure(material: NodeMaterial): void;
  119104. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119105. isReady(): boolean;
  119106. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119107. private _injectVertexCode;
  119108. private _writeOutput;
  119109. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119110. serialize(): any;
  119111. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119112. }
  119113. }
  119114. declare module BABYLON {
  119115. /**
  119116. * Interface used to configure the node material editor
  119117. */
  119118. export interface INodeMaterialEditorOptions {
  119119. /** Define the URl to load node editor script */
  119120. editorURL?: string;
  119121. }
  119122. /** @hidden */
  119123. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  119124. /** BONES */
  119125. NUM_BONE_INFLUENCERS: number;
  119126. BonesPerMesh: number;
  119127. BONETEXTURE: boolean;
  119128. /** MORPH TARGETS */
  119129. MORPHTARGETS: boolean;
  119130. MORPHTARGETS_NORMAL: boolean;
  119131. MORPHTARGETS_TANGENT: boolean;
  119132. MORPHTARGETS_UV: boolean;
  119133. NUM_MORPH_INFLUENCERS: number;
  119134. /** IMAGE PROCESSING */
  119135. IMAGEPROCESSING: boolean;
  119136. VIGNETTE: boolean;
  119137. VIGNETTEBLENDMODEMULTIPLY: boolean;
  119138. VIGNETTEBLENDMODEOPAQUE: boolean;
  119139. TONEMAPPING: boolean;
  119140. TONEMAPPING_ACES: boolean;
  119141. CONTRAST: boolean;
  119142. EXPOSURE: boolean;
  119143. COLORCURVES: boolean;
  119144. COLORGRADING: boolean;
  119145. COLORGRADING3D: boolean;
  119146. SAMPLER3DGREENDEPTH: boolean;
  119147. SAMPLER3DBGRMAP: boolean;
  119148. IMAGEPROCESSINGPOSTPROCESS: boolean;
  119149. /** MISC. */
  119150. BUMPDIRECTUV: number;
  119151. constructor();
  119152. setValue(name: string, value: boolean): void;
  119153. }
  119154. /**
  119155. * Class used to configure NodeMaterial
  119156. */
  119157. export interface INodeMaterialOptions {
  119158. /**
  119159. * Defines if blocks should emit comments
  119160. */
  119161. emitComments: boolean;
  119162. }
  119163. /**
  119164. * Class used to create a node based material built by assembling shader blocks
  119165. */
  119166. export class NodeMaterial extends PushMaterial {
  119167. private static _BuildIdGenerator;
  119168. private _options;
  119169. private _vertexCompilationState;
  119170. private _fragmentCompilationState;
  119171. private _sharedData;
  119172. private _buildId;
  119173. private _buildWasSuccessful;
  119174. private _cachedWorldViewMatrix;
  119175. private _cachedWorldViewProjectionMatrix;
  119176. private _optimizers;
  119177. private _animationFrame;
  119178. /** Define the URl to load node editor script */
  119179. static EditorURL: string;
  119180. private BJSNODEMATERIALEDITOR;
  119181. /** Get the inspector from bundle or global */
  119182. private _getGlobalNodeMaterialEditor;
  119183. /**
  119184. * 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)
  119185. */
  119186. ignoreAlpha: boolean;
  119187. /**
  119188. * Defines the maximum number of lights that can be used in the material
  119189. */
  119190. maxSimultaneousLights: number;
  119191. /**
  119192. * Observable raised when the material is built
  119193. */
  119194. onBuildObservable: Observable<NodeMaterial>;
  119195. /**
  119196. * Gets or sets the root nodes of the material vertex shader
  119197. */
  119198. _vertexOutputNodes: NodeMaterialBlock[];
  119199. /**
  119200. * Gets or sets the root nodes of the material fragment (pixel) shader
  119201. */
  119202. _fragmentOutputNodes: NodeMaterialBlock[];
  119203. /** Gets or sets options to control the node material overall behavior */
  119204. options: INodeMaterialOptions;
  119205. /**
  119206. * Default configuration related to image processing available in the standard Material.
  119207. */
  119208. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119209. /**
  119210. * Gets the image processing configuration used either in this material.
  119211. */
  119212. /**
  119213. * Sets the Default image processing configuration used either in the this material.
  119214. *
  119215. * If sets to null, the scene one is in use.
  119216. */
  119217. imageProcessingConfiguration: ImageProcessingConfiguration;
  119218. /**
  119219. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  119220. */
  119221. attachedBlocks: NodeMaterialBlock[];
  119222. /**
  119223. * Create a new node based material
  119224. * @param name defines the material name
  119225. * @param scene defines the hosting scene
  119226. * @param options defines creation option
  119227. */
  119228. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  119229. /**
  119230. * Gets the current class name of the material e.g. "NodeMaterial"
  119231. * @returns the class name
  119232. */
  119233. getClassName(): string;
  119234. /**
  119235. * Keep track of the image processing observer to allow dispose and replace.
  119236. */
  119237. private _imageProcessingObserver;
  119238. /**
  119239. * Attaches a new image processing configuration to the Standard Material.
  119240. * @param configuration
  119241. */
  119242. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  119243. /**
  119244. * Get a block by its name
  119245. * @param name defines the name of the block to retrieve
  119246. * @returns the required block or null if not found
  119247. */
  119248. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  119249. /**
  119250. * Get a block by its name
  119251. * @param predicate defines the predicate used to find the good candidate
  119252. * @returns the required block or null if not found
  119253. */
  119254. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  119255. /**
  119256. * Get an input block by its name
  119257. * @param predicate defines the predicate used to find the good candidate
  119258. * @returns the required input block or null if not found
  119259. */
  119260. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  119261. /**
  119262. * Gets the list of input blocks attached to this material
  119263. * @returns an array of InputBlocks
  119264. */
  119265. getInputBlocks(): InputBlock[];
  119266. /**
  119267. * Adds a new optimizer to the list of optimizers
  119268. * @param optimizer defines the optimizers to add
  119269. * @returns the current material
  119270. */
  119271. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119272. /**
  119273. * Remove an optimizer from the list of optimizers
  119274. * @param optimizer defines the optimizers to remove
  119275. * @returns the current material
  119276. */
  119277. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119278. /**
  119279. * Add a new block to the list of output nodes
  119280. * @param node defines the node to add
  119281. * @returns the current material
  119282. */
  119283. addOutputNode(node: NodeMaterialBlock): this;
  119284. /**
  119285. * Remove a block from the list of root nodes
  119286. * @param node defines the node to remove
  119287. * @returns the current material
  119288. */
  119289. removeOutputNode(node: NodeMaterialBlock): this;
  119290. private _addVertexOutputNode;
  119291. private _removeVertexOutputNode;
  119292. private _addFragmentOutputNode;
  119293. private _removeFragmentOutputNode;
  119294. /**
  119295. * Specifies if the material will require alpha blending
  119296. * @returns a boolean specifying if alpha blending is needed
  119297. */
  119298. needAlphaBlending(): boolean;
  119299. /**
  119300. * Specifies if this material should be rendered in alpha test mode
  119301. * @returns a boolean specifying if an alpha test is needed.
  119302. */
  119303. needAlphaTesting(): boolean;
  119304. private _initializeBlock;
  119305. private _resetDualBlocks;
  119306. /**
  119307. * Build the material and generates the inner effect
  119308. * @param verbose defines if the build should log activity
  119309. */
  119310. build(verbose?: boolean): void;
  119311. /**
  119312. * Runs an otpimization phase to try to improve the shader code
  119313. */
  119314. optimize(): void;
  119315. private _prepareDefinesForAttributes;
  119316. /**
  119317. * Get if the submesh is ready to be used and all its information available.
  119318. * Child classes can use it to update shaders
  119319. * @param mesh defines the mesh to check
  119320. * @param subMesh defines which submesh to check
  119321. * @param useInstances specifies that instances should be used
  119322. * @returns a boolean indicating that the submesh is ready or not
  119323. */
  119324. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  119325. /**
  119326. * Get a string representing the shaders built by the current node graph
  119327. */
  119328. readonly compiledShaders: string;
  119329. /**
  119330. * Binds the world matrix to the material
  119331. * @param world defines the world transformation matrix
  119332. */
  119333. bindOnlyWorldMatrix(world: Matrix): void;
  119334. /**
  119335. * Binds the submesh to this material by preparing the effect and shader to draw
  119336. * @param world defines the world transformation matrix
  119337. * @param mesh defines the mesh containing the submesh
  119338. * @param subMesh defines the submesh to bind the material to
  119339. */
  119340. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  119341. /**
  119342. * Gets the active textures from the material
  119343. * @returns an array of textures
  119344. */
  119345. getActiveTextures(): BaseTexture[];
  119346. /**
  119347. * Gets the list of texture blocks
  119348. * @returns an array of texture blocks
  119349. */
  119350. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  119351. /**
  119352. * Specifies if the material uses a texture
  119353. * @param texture defines the texture to check against the material
  119354. * @returns a boolean specifying if the material uses the texture
  119355. */
  119356. hasTexture(texture: BaseTexture): boolean;
  119357. /**
  119358. * Disposes the material
  119359. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  119360. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  119361. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  119362. */
  119363. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  119364. /** Creates the node editor window. */
  119365. private _createNodeEditor;
  119366. /**
  119367. * Launch the node material editor
  119368. * @param config Define the configuration of the editor
  119369. * @return a promise fulfilled when the node editor is visible
  119370. */
  119371. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  119372. /**
  119373. * Clear the current material
  119374. */
  119375. clear(): void;
  119376. /**
  119377. * Clear the current material and set it to a default state
  119378. */
  119379. setToDefault(): void;
  119380. /**
  119381. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  119382. * @param url defines the url to load from
  119383. * @returns a promise that will fullfil when the material is fully loaded
  119384. */
  119385. loadAsync(url: string): Promise<unknown>;
  119386. private _gatherBlocks;
  119387. /**
  119388. * Generate a string containing the code declaration required to create an equivalent of this material
  119389. * @returns a string
  119390. */
  119391. generateCode(): string;
  119392. /**
  119393. * Serializes this material in a JSON representation
  119394. * @returns the serialized material object
  119395. */
  119396. serialize(): any;
  119397. private _restoreConnections;
  119398. /**
  119399. * Clear the current graph and load a new one from a serialization object
  119400. * @param source defines the JSON representation of the material
  119401. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119402. */
  119403. loadFromSerialization(source: any, rootUrl?: string): void;
  119404. /**
  119405. * Creates a node material from parsed material data
  119406. * @param source defines the JSON representation of the material
  119407. * @param scene defines the hosting scene
  119408. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119409. * @returns a new node material
  119410. */
  119411. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  119412. /**
  119413. * Creates a new node material set to default basic configuration
  119414. * @param name defines the name of the material
  119415. * @param scene defines the hosting scene
  119416. * @returns a new NodeMaterial
  119417. */
  119418. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  119419. }
  119420. }
  119421. declare module BABYLON {
  119422. /**
  119423. * Block used to read a texture from a sampler
  119424. */
  119425. export class TextureBlock extends NodeMaterialBlock {
  119426. private _defineName;
  119427. private _samplerName;
  119428. private _transformedUVName;
  119429. private _textureTransformName;
  119430. private _textureInfoName;
  119431. private _mainUVName;
  119432. private _mainUVDefineName;
  119433. /**
  119434. * Gets or sets the texture associated with the node
  119435. */
  119436. texture: Nullable<Texture>;
  119437. /**
  119438. * Create a new TextureBlock
  119439. * @param name defines the block name
  119440. */
  119441. constructor(name: string);
  119442. /**
  119443. * Gets the current class name
  119444. * @returns the class name
  119445. */
  119446. getClassName(): string;
  119447. /**
  119448. * Gets the uv input component
  119449. */
  119450. readonly uv: NodeMaterialConnectionPoint;
  119451. /**
  119452. * Gets the rgba output component
  119453. */
  119454. readonly rgba: NodeMaterialConnectionPoint;
  119455. /**
  119456. * Gets the rgb output component
  119457. */
  119458. readonly rgb: NodeMaterialConnectionPoint;
  119459. /**
  119460. * Gets the r output component
  119461. */
  119462. readonly r: NodeMaterialConnectionPoint;
  119463. /**
  119464. * Gets the g output component
  119465. */
  119466. readonly g: NodeMaterialConnectionPoint;
  119467. /**
  119468. * Gets the b output component
  119469. */
  119470. readonly b: NodeMaterialConnectionPoint;
  119471. /**
  119472. * Gets the a output component
  119473. */
  119474. readonly a: NodeMaterialConnectionPoint;
  119475. readonly target: NodeMaterialBlockTargets;
  119476. autoConfigure(material: NodeMaterial): void;
  119477. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119478. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119479. isReady(): boolean;
  119480. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119481. private readonly _isMixed;
  119482. private _injectVertexCode;
  119483. private _writeOutput;
  119484. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119485. protected _dumpPropertiesCode(): string;
  119486. serialize(): any;
  119487. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119488. }
  119489. }
  119490. declare module BABYLON {
  119491. /**
  119492. * Class used to store shared data between 2 NodeMaterialBuildState
  119493. */
  119494. export class NodeMaterialBuildStateSharedData {
  119495. /**
  119496. * Gets the list of emitted varyings
  119497. */
  119498. temps: string[];
  119499. /**
  119500. * Gets the list of emitted varyings
  119501. */
  119502. varyings: string[];
  119503. /**
  119504. * Gets the varying declaration string
  119505. */
  119506. varyingDeclaration: string;
  119507. /**
  119508. * Input blocks
  119509. */
  119510. inputBlocks: InputBlock[];
  119511. /**
  119512. * Input blocks
  119513. */
  119514. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  119515. /**
  119516. * Bindable blocks (Blocks that need to set data to the effect)
  119517. */
  119518. bindableBlocks: NodeMaterialBlock[];
  119519. /**
  119520. * List of blocks that can provide a compilation fallback
  119521. */
  119522. blocksWithFallbacks: NodeMaterialBlock[];
  119523. /**
  119524. * List of blocks that can provide a define update
  119525. */
  119526. blocksWithDefines: NodeMaterialBlock[];
  119527. /**
  119528. * List of blocks that can provide a repeatable content
  119529. */
  119530. repeatableContentBlocks: NodeMaterialBlock[];
  119531. /**
  119532. * List of blocks that can provide a dynamic list of uniforms
  119533. */
  119534. dynamicUniformBlocks: NodeMaterialBlock[];
  119535. /**
  119536. * List of blocks that can block the isReady function for the material
  119537. */
  119538. blockingBlocks: NodeMaterialBlock[];
  119539. /**
  119540. * Gets the list of animated inputs
  119541. */
  119542. animatedInputs: InputBlock[];
  119543. /**
  119544. * Build Id used to avoid multiple recompilations
  119545. */
  119546. buildId: number;
  119547. /** List of emitted variables */
  119548. variableNames: {
  119549. [key: string]: number;
  119550. };
  119551. /** List of emitted defines */
  119552. defineNames: {
  119553. [key: string]: number;
  119554. };
  119555. /** Should emit comments? */
  119556. emitComments: boolean;
  119557. /** Emit build activity */
  119558. verbose: boolean;
  119559. /** Gets or sets the hosting scene */
  119560. scene: Scene;
  119561. /**
  119562. * Gets the compilation hints emitted at compilation time
  119563. */
  119564. hints: {
  119565. needWorldViewMatrix: boolean;
  119566. needWorldViewProjectionMatrix: boolean;
  119567. needAlphaBlending: boolean;
  119568. needAlphaTesting: boolean;
  119569. };
  119570. /**
  119571. * List of compilation checks
  119572. */
  119573. checks: {
  119574. emitVertex: boolean;
  119575. emitFragment: boolean;
  119576. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  119577. };
  119578. /** Creates a new shared data */
  119579. constructor();
  119580. /**
  119581. * Emits console errors and exceptions if there is a failing check
  119582. */
  119583. emitErrors(): void;
  119584. }
  119585. }
  119586. declare module BABYLON {
  119587. /**
  119588. * Class used to store node based material build state
  119589. */
  119590. export class NodeMaterialBuildState {
  119591. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  119592. supportUniformBuffers: boolean;
  119593. /**
  119594. * Gets the list of emitted attributes
  119595. */
  119596. attributes: string[];
  119597. /**
  119598. * Gets the list of emitted uniforms
  119599. */
  119600. uniforms: string[];
  119601. /**
  119602. * Gets the list of emitted constants
  119603. */
  119604. constants: string[];
  119605. /**
  119606. * Gets the list of emitted uniform buffers
  119607. */
  119608. uniformBuffers: string[];
  119609. /**
  119610. * Gets the list of emitted samplers
  119611. */
  119612. samplers: string[];
  119613. /**
  119614. * Gets the list of emitted functions
  119615. */
  119616. functions: {
  119617. [key: string]: string;
  119618. };
  119619. /**
  119620. * Gets the list of emitted extensions
  119621. */
  119622. extensions: {
  119623. [key: string]: string;
  119624. };
  119625. /**
  119626. * Gets the target of the compilation state
  119627. */
  119628. target: NodeMaterialBlockTargets;
  119629. /**
  119630. * Gets the list of emitted counters
  119631. */
  119632. counters: {
  119633. [key: string]: number;
  119634. };
  119635. /**
  119636. * Shared data between multiple NodeMaterialBuildState instances
  119637. */
  119638. sharedData: NodeMaterialBuildStateSharedData;
  119639. /** @hidden */
  119640. _vertexState: NodeMaterialBuildState;
  119641. /** @hidden */
  119642. _attributeDeclaration: string;
  119643. /** @hidden */
  119644. _uniformDeclaration: string;
  119645. /** @hidden */
  119646. _constantDeclaration: string;
  119647. /** @hidden */
  119648. _samplerDeclaration: string;
  119649. /** @hidden */
  119650. _varyingTransfer: string;
  119651. private _repeatableContentAnchorIndex;
  119652. /** @hidden */
  119653. _builtCompilationString: string;
  119654. /**
  119655. * Gets the emitted compilation strings
  119656. */
  119657. compilationString: string;
  119658. /**
  119659. * Finalize the compilation strings
  119660. * @param state defines the current compilation state
  119661. */
  119662. finalize(state: NodeMaterialBuildState): void;
  119663. /** @hidden */
  119664. readonly _repeatableContentAnchor: string;
  119665. /** @hidden */
  119666. _getFreeVariableName(prefix: string): string;
  119667. /** @hidden */
  119668. _getFreeDefineName(prefix: string): string;
  119669. /** @hidden */
  119670. _excludeVariableName(name: string): void;
  119671. /** @hidden */
  119672. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  119673. /** @hidden */
  119674. _emitExtension(name: string, extension: string): void;
  119675. /** @hidden */
  119676. _emitFunction(name: string, code: string, comments: string): void;
  119677. /** @hidden */
  119678. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  119679. replaceStrings?: {
  119680. search: RegExp;
  119681. replace: string;
  119682. }[];
  119683. repeatKey?: string;
  119684. }): string;
  119685. /** @hidden */
  119686. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  119687. repeatKey?: string;
  119688. removeAttributes?: boolean;
  119689. removeUniforms?: boolean;
  119690. removeVaryings?: boolean;
  119691. removeIfDef?: boolean;
  119692. replaceStrings?: {
  119693. search: RegExp;
  119694. replace: string;
  119695. }[];
  119696. }, storeKey?: string): void;
  119697. /** @hidden */
  119698. _registerTempVariable(name: string): boolean;
  119699. /** @hidden */
  119700. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  119701. /** @hidden */
  119702. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  119703. }
  119704. }
  119705. declare module BABYLON {
  119706. /**
  119707. * Defines a block that can be used inside a node based material
  119708. */
  119709. export class NodeMaterialBlock {
  119710. private _buildId;
  119711. private _buildTarget;
  119712. private _target;
  119713. private _isFinalMerger;
  119714. private _isInput;
  119715. /** @hidden */
  119716. _codeVariableName: string;
  119717. /** @hidden */
  119718. _inputs: NodeMaterialConnectionPoint[];
  119719. /** @hidden */
  119720. _outputs: NodeMaterialConnectionPoint[];
  119721. /** @hidden */
  119722. _preparationId: number;
  119723. /**
  119724. * Gets or sets the name of the block
  119725. */
  119726. name: string;
  119727. /**
  119728. * Gets or sets the unique id of the node
  119729. */
  119730. uniqueId: number;
  119731. /**
  119732. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  119733. */
  119734. readonly isFinalMerger: boolean;
  119735. /**
  119736. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  119737. */
  119738. readonly isInput: boolean;
  119739. /**
  119740. * Gets or sets the build Id
  119741. */
  119742. buildId: number;
  119743. /**
  119744. * Gets or sets the target of the block
  119745. */
  119746. target: NodeMaterialBlockTargets;
  119747. /**
  119748. * Gets the list of input points
  119749. */
  119750. readonly inputs: NodeMaterialConnectionPoint[];
  119751. /** Gets the list of output points */
  119752. readonly outputs: NodeMaterialConnectionPoint[];
  119753. /**
  119754. * Find an input by its name
  119755. * @param name defines the name of the input to look for
  119756. * @returns the input or null if not found
  119757. */
  119758. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  119759. /**
  119760. * Find an output by its name
  119761. * @param name defines the name of the outputto look for
  119762. * @returns the output or null if not found
  119763. */
  119764. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  119765. /**
  119766. * Creates a new NodeMaterialBlock
  119767. * @param name defines the block name
  119768. * @param target defines the target of that block (Vertex by default)
  119769. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  119770. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  119771. */
  119772. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  119773. /**
  119774. * Initialize the block and prepare the context for build
  119775. * @param state defines the state that will be used for the build
  119776. */
  119777. initialize(state: NodeMaterialBuildState): void;
  119778. /**
  119779. * Bind data to effect. Will only be called for blocks with isBindable === true
  119780. * @param effect defines the effect to bind data to
  119781. * @param nodeMaterial defines the hosting NodeMaterial
  119782. * @param mesh defines the mesh that will be rendered
  119783. */
  119784. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119785. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  119786. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  119787. protected _writeFloat(value: number): string;
  119788. /**
  119789. * Gets the current class name e.g. "NodeMaterialBlock"
  119790. * @returns the class name
  119791. */
  119792. getClassName(): string;
  119793. /**
  119794. * Register a new input. Must be called inside a block constructor
  119795. * @param name defines the connection point name
  119796. * @param type defines the connection point type
  119797. * @param isOptional defines a boolean indicating that this input can be omitted
  119798. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  119799. * @returns the current block
  119800. */
  119801. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  119802. /**
  119803. * Register a new output. Must be called inside a block constructor
  119804. * @param name defines the connection point name
  119805. * @param type defines the connection point type
  119806. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  119807. * @returns the current block
  119808. */
  119809. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  119810. /**
  119811. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  119812. * @param forOutput defines an optional connection point to check compatibility with
  119813. * @returns the first available input or null
  119814. */
  119815. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  119816. /**
  119817. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  119818. * @param forBlock defines an optional block to check compatibility with
  119819. * @returns the first available input or null
  119820. */
  119821. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  119822. /**
  119823. * Gets the sibling of the given output
  119824. * @param current defines the current output
  119825. * @returns the next output in the list or null
  119826. */
  119827. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  119828. /**
  119829. * Connect current block with another block
  119830. * @param other defines the block to connect with
  119831. * @param options define the various options to help pick the right connections
  119832. * @returns the current block
  119833. */
  119834. connectTo(other: NodeMaterialBlock, options?: {
  119835. input?: string;
  119836. output?: string;
  119837. outputSwizzle?: string;
  119838. }): this | undefined;
  119839. protected _buildBlock(state: NodeMaterialBuildState): void;
  119840. /**
  119841. * Add uniforms, samplers and uniform buffers at compilation time
  119842. * @param state defines the state to update
  119843. * @param nodeMaterial defines the node material requesting the update
  119844. * @param defines defines the material defines to update
  119845. */
  119846. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119847. /**
  119848. * Add potential fallbacks if shader compilation fails
  119849. * @param mesh defines the mesh to be rendered
  119850. * @param fallbacks defines the current prioritized list of fallbacks
  119851. */
  119852. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  119853. /**
  119854. * Initialize defines for shader compilation
  119855. * @param mesh defines the mesh to be rendered
  119856. * @param nodeMaterial defines the node material requesting the update
  119857. * @param defines defines the material defines to update
  119858. * @param useInstances specifies that instances should be used
  119859. */
  119860. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119861. /**
  119862. * Update defines for shader compilation
  119863. * @param mesh defines the mesh to be rendered
  119864. * @param nodeMaterial defines the node material requesting the update
  119865. * @param defines defines the material defines to update
  119866. * @param useInstances specifies that instances should be used
  119867. */
  119868. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119869. /**
  119870. * Lets the block try to connect some inputs automatically
  119871. * @param material defines the hosting NodeMaterial
  119872. */
  119873. autoConfigure(material: NodeMaterial): void;
  119874. /**
  119875. * Function called when a block is declared as repeatable content generator
  119876. * @param vertexShaderState defines the current compilation state for the vertex shader
  119877. * @param fragmentShaderState defines the current compilation state for the fragment shader
  119878. * @param mesh defines the mesh to be rendered
  119879. * @param defines defines the material defines to update
  119880. */
  119881. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  119882. /**
  119883. * Checks if the block is ready
  119884. * @param mesh defines the mesh to be rendered
  119885. * @param nodeMaterial defines the node material requesting the update
  119886. * @param defines defines the material defines to update
  119887. * @param useInstances specifies that instances should be used
  119888. * @returns true if the block is ready
  119889. */
  119890. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  119891. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  119892. private _processBuild;
  119893. /**
  119894. * Compile the current node and generate the shader code
  119895. * @param state defines the current compilation state (uniforms, samplers, current string)
  119896. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  119897. * @returns true if already built
  119898. */
  119899. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  119900. protected _inputRename(name: string): string;
  119901. protected _outputRename(name: string): string;
  119902. protected _dumpPropertiesCode(): string;
  119903. /** @hidden */
  119904. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  119905. /**
  119906. * Clone the current block to a new identical block
  119907. * @param scene defines the hosting scene
  119908. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119909. * @returns a copy of the current block
  119910. */
  119911. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  119912. /**
  119913. * Serializes this block in a JSON representation
  119914. * @returns the serialized block object
  119915. */
  119916. serialize(): any;
  119917. /** @hidden */
  119918. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119919. }
  119920. }
  119921. declare module BABYLON {
  119922. /**
  119923. * Enum defining the type of animations supported by InputBlock
  119924. */
  119925. export enum AnimatedInputBlockTypes {
  119926. /** No animation */
  119927. None = 0,
  119928. /** Time based animation. Will only work for floats */
  119929. Time = 1
  119930. }
  119931. }
  119932. declare module BABYLON {
  119933. /**
  119934. * Block used to expose an input value
  119935. */
  119936. export class InputBlock extends NodeMaterialBlock {
  119937. private _mode;
  119938. private _associatedVariableName;
  119939. private _storedValue;
  119940. private _valueCallback;
  119941. private _type;
  119942. private _animationType;
  119943. /** Gets or set a value used to limit the range of float values */
  119944. min: number;
  119945. /** Gets or set a value used to limit the range of float values */
  119946. max: number;
  119947. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  119948. matrixMode: number;
  119949. /** @hidden */
  119950. _systemValue: Nullable<NodeMaterialSystemValues>;
  119951. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  119952. visibleInInspector: boolean;
  119953. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  119954. isConstant: boolean;
  119955. /**
  119956. * Gets or sets the connection point type (default is float)
  119957. */
  119958. readonly type: NodeMaterialBlockConnectionPointTypes;
  119959. /**
  119960. * Creates a new InputBlock
  119961. * @param name defines the block name
  119962. * @param target defines the target of that block (Vertex by default)
  119963. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  119964. */
  119965. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  119966. /**
  119967. * Gets the output component
  119968. */
  119969. readonly output: NodeMaterialConnectionPoint;
  119970. /**
  119971. * Set the source of this connection point to a vertex attribute
  119972. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  119973. * @returns the current connection point
  119974. */
  119975. setAsAttribute(attributeName?: string): InputBlock;
  119976. /**
  119977. * Set the source of this connection point to a system value
  119978. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  119979. * @returns the current connection point
  119980. */
  119981. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  119982. /**
  119983. * Gets or sets the value of that point.
  119984. * Please note that this value will be ignored if valueCallback is defined
  119985. */
  119986. value: any;
  119987. /**
  119988. * Gets or sets a callback used to get the value of that point.
  119989. * Please note that setting this value will force the connection point to ignore the value property
  119990. */
  119991. valueCallback: () => any;
  119992. /**
  119993. * Gets or sets the associated variable name in the shader
  119994. */
  119995. associatedVariableName: string;
  119996. /** Gets or sets the type of animation applied to the input */
  119997. animationType: AnimatedInputBlockTypes;
  119998. /**
  119999. * Gets a boolean indicating that this connection point not defined yet
  120000. */
  120001. readonly isUndefined: boolean;
  120002. /**
  120003. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  120004. * In this case the connection point name must be the name of the uniform to use.
  120005. * Can only be set on inputs
  120006. */
  120007. isUniform: boolean;
  120008. /**
  120009. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  120010. * In this case the connection point name must be the name of the attribute to use
  120011. * Can only be set on inputs
  120012. */
  120013. isAttribute: boolean;
  120014. /**
  120015. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  120016. * Can only be set on exit points
  120017. */
  120018. isVarying: boolean;
  120019. /**
  120020. * Gets a boolean indicating that the current connection point is a system value
  120021. */
  120022. readonly isSystemValue: boolean;
  120023. /**
  120024. * Gets or sets the current well known value or null if not defined as a system value
  120025. */
  120026. systemValue: Nullable<NodeMaterialSystemValues>;
  120027. /**
  120028. * Gets the current class name
  120029. * @returns the class name
  120030. */
  120031. getClassName(): string;
  120032. /**
  120033. * Animate the input if animationType !== None
  120034. * @param scene defines the rendering scene
  120035. */
  120036. animate(scene: Scene): void;
  120037. private _emitDefine;
  120038. initialize(state: NodeMaterialBuildState): void;
  120039. /**
  120040. * Set the input block to its default value (based on its type)
  120041. */
  120042. setDefaultValue(): void;
  120043. private _emitConstant;
  120044. private _emit;
  120045. /** @hidden */
  120046. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  120047. /** @hidden */
  120048. _transmit(effect: Effect, scene: Scene): void;
  120049. protected _buildBlock(state: NodeMaterialBuildState): void;
  120050. protected _dumpPropertiesCode(): string;
  120051. serialize(): any;
  120052. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120053. }
  120054. }
  120055. declare module BABYLON {
  120056. /**
  120057. * Defines a connection point for a block
  120058. */
  120059. export class NodeMaterialConnectionPoint {
  120060. /** @hidden */
  120061. _ownerBlock: NodeMaterialBlock;
  120062. /** @hidden */
  120063. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120064. private _endpoints;
  120065. private _associatedVariableName;
  120066. /** @hidden */
  120067. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120068. /** @hidden */
  120069. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120070. private _type;
  120071. /** @hidden */
  120072. _enforceAssociatedVariableName: boolean;
  120073. /**
  120074. * Gets or sets the additional types supported by this connection point
  120075. */
  120076. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120077. /**
  120078. * Gets or sets the additional types excluded by this connection point
  120079. */
  120080. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120081. /**
  120082. * Gets or sets the associated variable name in the shader
  120083. */
  120084. associatedVariableName: string;
  120085. /**
  120086. * Gets or sets the connection point type (default is float)
  120087. */
  120088. type: NodeMaterialBlockConnectionPointTypes;
  120089. /**
  120090. * Gets or sets the connection point name
  120091. */
  120092. name: string;
  120093. /**
  120094. * Gets or sets a boolean indicating that this connection point can be omitted
  120095. */
  120096. isOptional: boolean;
  120097. /**
  120098. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  120099. */
  120100. define: string;
  120101. /** Gets or sets the target of that connection point */
  120102. target: NodeMaterialBlockTargets;
  120103. /**
  120104. * Gets a boolean indicating that the current point is connected
  120105. */
  120106. readonly isConnected: boolean;
  120107. /**
  120108. * Gets a boolean indicating that the current point is connected to an input block
  120109. */
  120110. readonly isConnectedToInputBlock: boolean;
  120111. /**
  120112. * Gets a the connected input block (if any)
  120113. */
  120114. readonly connectInputBlock: Nullable<InputBlock>;
  120115. /** Get the other side of the connection (if any) */
  120116. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120117. /** Get the block that owns this connection point */
  120118. readonly ownerBlock: NodeMaterialBlock;
  120119. /** Get the block connected on the other side of this connection (if any) */
  120120. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  120121. /** Get the block connected on the endpoints of this connection (if any) */
  120122. readonly connectedBlocks: Array<NodeMaterialBlock>;
  120123. /** Gets the list of connected endpoints */
  120124. readonly endpoints: NodeMaterialConnectionPoint[];
  120125. /** Gets a boolean indicating if that output point is connected to at least one input */
  120126. readonly hasEndpoints: boolean;
  120127. /**
  120128. * Creates a new connection point
  120129. * @param name defines the connection point name
  120130. * @param ownerBlock defines the block hosting this connection point
  120131. */
  120132. constructor(name: string, ownerBlock: NodeMaterialBlock);
  120133. /**
  120134. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  120135. * @returns the class name
  120136. */
  120137. getClassName(): string;
  120138. /**
  120139. * Gets an boolean indicating if the current point can be connected to another point
  120140. * @param connectionPoint defines the other connection point
  120141. * @returns true if the connection is possible
  120142. */
  120143. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  120144. /**
  120145. * Connect this point to another connection point
  120146. * @param connectionPoint defines the other connection point
  120147. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  120148. * @returns the current connection point
  120149. */
  120150. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  120151. /**
  120152. * Disconnect this point from one of his endpoint
  120153. * @param endpoint defines the other connection point
  120154. * @returns the current connection point
  120155. */
  120156. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  120157. /**
  120158. * Serializes this point in a JSON representation
  120159. * @returns the serialized point object
  120160. */
  120161. serialize(): any;
  120162. }
  120163. }
  120164. declare module BABYLON {
  120165. /**
  120166. * Block used to add support for vertex skinning (bones)
  120167. */
  120168. export class BonesBlock extends NodeMaterialBlock {
  120169. /**
  120170. * Creates a new BonesBlock
  120171. * @param name defines the block name
  120172. */
  120173. constructor(name: string);
  120174. /**
  120175. * Initialize the block and prepare the context for build
  120176. * @param state defines the state that will be used for the build
  120177. */
  120178. initialize(state: NodeMaterialBuildState): void;
  120179. /**
  120180. * Gets the current class name
  120181. * @returns the class name
  120182. */
  120183. getClassName(): string;
  120184. /**
  120185. * Gets the matrix indices input component
  120186. */
  120187. readonly matricesIndices: NodeMaterialConnectionPoint;
  120188. /**
  120189. * Gets the matrix weights input component
  120190. */
  120191. readonly matricesWeights: NodeMaterialConnectionPoint;
  120192. /**
  120193. * Gets the extra matrix indices input component
  120194. */
  120195. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  120196. /**
  120197. * Gets the extra matrix weights input component
  120198. */
  120199. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  120200. /**
  120201. * Gets the world input component
  120202. */
  120203. readonly world: NodeMaterialConnectionPoint;
  120204. /**
  120205. * Gets the output component
  120206. */
  120207. readonly output: NodeMaterialConnectionPoint;
  120208. autoConfigure(material: NodeMaterial): void;
  120209. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120210. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120211. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120212. protected _buildBlock(state: NodeMaterialBuildState): this;
  120213. }
  120214. }
  120215. declare module BABYLON {
  120216. /**
  120217. * Block used to add support for instances
  120218. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  120219. */
  120220. export class InstancesBlock extends NodeMaterialBlock {
  120221. /**
  120222. * Creates a new InstancesBlock
  120223. * @param name defines the block name
  120224. */
  120225. constructor(name: string);
  120226. /**
  120227. * Gets the current class name
  120228. * @returns the class name
  120229. */
  120230. getClassName(): string;
  120231. /**
  120232. * Gets the first world row input component
  120233. */
  120234. readonly world0: NodeMaterialConnectionPoint;
  120235. /**
  120236. * Gets the second world row input component
  120237. */
  120238. readonly world1: NodeMaterialConnectionPoint;
  120239. /**
  120240. * Gets the third world row input component
  120241. */
  120242. readonly world2: NodeMaterialConnectionPoint;
  120243. /**
  120244. * Gets the forth world row input component
  120245. */
  120246. readonly world3: NodeMaterialConnectionPoint;
  120247. /**
  120248. * Gets the world input component
  120249. */
  120250. readonly world: NodeMaterialConnectionPoint;
  120251. /**
  120252. * Gets the output component
  120253. */
  120254. readonly output: NodeMaterialConnectionPoint;
  120255. autoConfigure(material: NodeMaterial): void;
  120256. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120257. protected _buildBlock(state: NodeMaterialBuildState): this;
  120258. }
  120259. }
  120260. declare module BABYLON {
  120261. /**
  120262. * Block used to add morph targets support to vertex shader
  120263. */
  120264. export class MorphTargetsBlock extends NodeMaterialBlock {
  120265. private _repeatableContentAnchor;
  120266. private _repeatebleContentGenerated;
  120267. /**
  120268. * Create a new MorphTargetsBlock
  120269. * @param name defines the block name
  120270. */
  120271. constructor(name: string);
  120272. /**
  120273. * Gets the current class name
  120274. * @returns the class name
  120275. */
  120276. getClassName(): string;
  120277. /**
  120278. * Gets the position input component
  120279. */
  120280. readonly position: NodeMaterialConnectionPoint;
  120281. /**
  120282. * Gets the normal input component
  120283. */
  120284. readonly normal: NodeMaterialConnectionPoint;
  120285. /**
  120286. * Gets the tangent input component
  120287. */
  120288. readonly tangent: NodeMaterialConnectionPoint;
  120289. /**
  120290. * Gets the tangent input component
  120291. */
  120292. readonly uv: NodeMaterialConnectionPoint;
  120293. /**
  120294. * Gets the position output component
  120295. */
  120296. readonly positionOutput: NodeMaterialConnectionPoint;
  120297. /**
  120298. * Gets the normal output component
  120299. */
  120300. readonly normalOutput: NodeMaterialConnectionPoint;
  120301. /**
  120302. * Gets the tangent output component
  120303. */
  120304. readonly tangentOutput: NodeMaterialConnectionPoint;
  120305. /**
  120306. * Gets the tangent output component
  120307. */
  120308. readonly uvOutput: NodeMaterialConnectionPoint;
  120309. initialize(state: NodeMaterialBuildState): void;
  120310. autoConfigure(material: NodeMaterial): void;
  120311. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120312. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120313. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120314. protected _buildBlock(state: NodeMaterialBuildState): this;
  120315. }
  120316. }
  120317. declare module BABYLON {
  120318. /**
  120319. * Block used to get data information from a light
  120320. */
  120321. export class LightInformationBlock extends NodeMaterialBlock {
  120322. private _lightDataUniformName;
  120323. private _lightColorUniformName;
  120324. private _lightTypeDefineName;
  120325. /**
  120326. * Gets or sets the light associated with this block
  120327. */
  120328. light: Nullable<Light>;
  120329. /**
  120330. * Creates a new LightInformationBlock
  120331. * @param name defines the block name
  120332. */
  120333. constructor(name: string);
  120334. /**
  120335. * Gets the current class name
  120336. * @returns the class name
  120337. */
  120338. getClassName(): string;
  120339. /**
  120340. * Gets the world position input component
  120341. */
  120342. readonly worldPosition: NodeMaterialConnectionPoint;
  120343. /**
  120344. * Gets the direction output component
  120345. */
  120346. readonly direction: NodeMaterialConnectionPoint;
  120347. /**
  120348. * Gets the direction output component
  120349. */
  120350. readonly color: NodeMaterialConnectionPoint;
  120351. /**
  120352. * Gets the direction output component
  120353. */
  120354. readonly intensity: NodeMaterialConnectionPoint;
  120355. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120356. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120357. protected _buildBlock(state: NodeMaterialBuildState): this;
  120358. serialize(): any;
  120359. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120360. }
  120361. }
  120362. declare module BABYLON {
  120363. /**
  120364. * Block used to add image processing support to fragment shader
  120365. */
  120366. export class ImageProcessingBlock extends NodeMaterialBlock {
  120367. /**
  120368. * Create a new ImageProcessingBlock
  120369. * @param name defines the block name
  120370. */
  120371. constructor(name: string);
  120372. /**
  120373. * Gets the current class name
  120374. * @returns the class name
  120375. */
  120376. getClassName(): string;
  120377. /**
  120378. * Gets the color input component
  120379. */
  120380. readonly color: NodeMaterialConnectionPoint;
  120381. /**
  120382. * Gets the output component
  120383. */
  120384. readonly output: NodeMaterialConnectionPoint;
  120385. /**
  120386. * Initialize the block and prepare the context for build
  120387. * @param state defines the state that will be used for the build
  120388. */
  120389. initialize(state: NodeMaterialBuildState): void;
  120390. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  120391. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120392. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120393. protected _buildBlock(state: NodeMaterialBuildState): this;
  120394. }
  120395. }
  120396. declare module BABYLON {
  120397. /**
  120398. * Block used to pertub normals based on a normal map
  120399. */
  120400. export class PerturbNormalBlock extends NodeMaterialBlock {
  120401. private _tangentSpaceParameterName;
  120402. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  120403. invertX: boolean;
  120404. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  120405. invertY: boolean;
  120406. /**
  120407. * Create a new PerturbNormalBlock
  120408. * @param name defines the block name
  120409. */
  120410. constructor(name: string);
  120411. /**
  120412. * Gets the current class name
  120413. * @returns the class name
  120414. */
  120415. getClassName(): string;
  120416. /**
  120417. * Gets the world position input component
  120418. */
  120419. readonly worldPosition: NodeMaterialConnectionPoint;
  120420. /**
  120421. * Gets the world normal input component
  120422. */
  120423. readonly worldNormal: NodeMaterialConnectionPoint;
  120424. /**
  120425. * Gets the uv input component
  120426. */
  120427. readonly uv: NodeMaterialConnectionPoint;
  120428. /**
  120429. * Gets the normal map color input component
  120430. */
  120431. readonly normalMapColor: NodeMaterialConnectionPoint;
  120432. /**
  120433. * Gets the strength input component
  120434. */
  120435. readonly strength: NodeMaterialConnectionPoint;
  120436. /**
  120437. * Gets the output component
  120438. */
  120439. readonly output: NodeMaterialConnectionPoint;
  120440. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120441. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120442. autoConfigure(material: NodeMaterial): void;
  120443. protected _buildBlock(state: NodeMaterialBuildState): this;
  120444. protected _dumpPropertiesCode(): string;
  120445. serialize(): any;
  120446. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120447. }
  120448. }
  120449. declare module BABYLON {
  120450. /**
  120451. * Block used to discard a pixel if a value is smaller than a cutoff
  120452. */
  120453. export class DiscardBlock extends NodeMaterialBlock {
  120454. /**
  120455. * Create a new DiscardBlock
  120456. * @param name defines the block name
  120457. */
  120458. constructor(name: string);
  120459. /**
  120460. * Gets the current class name
  120461. * @returns the class name
  120462. */
  120463. getClassName(): string;
  120464. /**
  120465. * Gets the color input component
  120466. */
  120467. readonly value: NodeMaterialConnectionPoint;
  120468. /**
  120469. * Gets the cutoff input component
  120470. */
  120471. readonly cutoff: NodeMaterialConnectionPoint;
  120472. protected _buildBlock(state: NodeMaterialBuildState): this;
  120473. }
  120474. }
  120475. declare module BABYLON {
  120476. /**
  120477. * Block used to add support for scene fog
  120478. */
  120479. export class FogBlock extends NodeMaterialBlock {
  120480. private _fogDistanceName;
  120481. private _fogParameters;
  120482. /**
  120483. * Create a new FogBlock
  120484. * @param name defines the block name
  120485. */
  120486. constructor(name: string);
  120487. /**
  120488. * Gets the current class name
  120489. * @returns the class name
  120490. */
  120491. getClassName(): string;
  120492. /**
  120493. * Gets the world position input component
  120494. */
  120495. readonly worldPosition: NodeMaterialConnectionPoint;
  120496. /**
  120497. * Gets the view input component
  120498. */
  120499. readonly view: NodeMaterialConnectionPoint;
  120500. /**
  120501. * Gets the color input component
  120502. */
  120503. readonly input: NodeMaterialConnectionPoint;
  120504. /**
  120505. * Gets the fog color input component
  120506. */
  120507. readonly fogColor: NodeMaterialConnectionPoint;
  120508. /**
  120509. * Gets the output component
  120510. */
  120511. readonly output: NodeMaterialConnectionPoint;
  120512. autoConfigure(material: NodeMaterial): void;
  120513. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120514. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120515. protected _buildBlock(state: NodeMaterialBuildState): this;
  120516. }
  120517. }
  120518. declare module BABYLON {
  120519. /**
  120520. * Block used to add light in the fragment shader
  120521. */
  120522. export class LightBlock extends NodeMaterialBlock {
  120523. private _lightId;
  120524. /**
  120525. * Gets or sets the light associated with this block
  120526. */
  120527. light: Nullable<Light>;
  120528. /**
  120529. * Create a new LightBlock
  120530. * @param name defines the block name
  120531. */
  120532. constructor(name: string);
  120533. /**
  120534. * Gets the current class name
  120535. * @returns the class name
  120536. */
  120537. getClassName(): string;
  120538. /**
  120539. * Gets the world position input component
  120540. */
  120541. readonly worldPosition: NodeMaterialConnectionPoint;
  120542. /**
  120543. * Gets the world normal input component
  120544. */
  120545. readonly worldNormal: NodeMaterialConnectionPoint;
  120546. /**
  120547. * Gets the camera (or eye) position component
  120548. */
  120549. readonly cameraPosition: NodeMaterialConnectionPoint;
  120550. /**
  120551. * Gets the glossiness component
  120552. */
  120553. readonly glossiness: NodeMaterialConnectionPoint;
  120554. /**
  120555. * Gets the diffuse color component
  120556. */
  120557. readonly diffuseColor: NodeMaterialConnectionPoint;
  120558. /**
  120559. * Gets the specular color component
  120560. */
  120561. readonly specularColor: NodeMaterialConnectionPoint;
  120562. /**
  120563. * Gets the diffuse output component
  120564. */
  120565. readonly diffuseOutput: NodeMaterialConnectionPoint;
  120566. /**
  120567. * Gets the specular output component
  120568. */
  120569. readonly specularOutput: NodeMaterialConnectionPoint;
  120570. autoConfigure(material: NodeMaterial): void;
  120571. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120572. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120573. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120574. private _injectVertexCode;
  120575. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120576. serialize(): any;
  120577. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120578. }
  120579. }
  120580. declare module BABYLON {
  120581. /**
  120582. * Block used to multiply 2 values
  120583. */
  120584. export class MultiplyBlock extends NodeMaterialBlock {
  120585. /**
  120586. * Creates a new MultiplyBlock
  120587. * @param name defines the block name
  120588. */
  120589. constructor(name: string);
  120590. /**
  120591. * Gets the current class name
  120592. * @returns the class name
  120593. */
  120594. getClassName(): string;
  120595. /**
  120596. * Gets the left operand input component
  120597. */
  120598. readonly left: NodeMaterialConnectionPoint;
  120599. /**
  120600. * Gets the right operand input component
  120601. */
  120602. readonly right: NodeMaterialConnectionPoint;
  120603. /**
  120604. * Gets the output component
  120605. */
  120606. readonly output: NodeMaterialConnectionPoint;
  120607. protected _buildBlock(state: NodeMaterialBuildState): this;
  120608. }
  120609. }
  120610. declare module BABYLON {
  120611. /**
  120612. * Block used to add 2 vectors
  120613. */
  120614. export class AddBlock extends NodeMaterialBlock {
  120615. /**
  120616. * Creates a new AddBlock
  120617. * @param name defines the block name
  120618. */
  120619. constructor(name: string);
  120620. /**
  120621. * Gets the current class name
  120622. * @returns the class name
  120623. */
  120624. getClassName(): string;
  120625. /**
  120626. * Gets the left operand input component
  120627. */
  120628. readonly left: NodeMaterialConnectionPoint;
  120629. /**
  120630. * Gets the right operand input component
  120631. */
  120632. readonly right: NodeMaterialConnectionPoint;
  120633. /**
  120634. * Gets the output component
  120635. */
  120636. readonly output: NodeMaterialConnectionPoint;
  120637. protected _buildBlock(state: NodeMaterialBuildState): this;
  120638. }
  120639. }
  120640. declare module BABYLON {
  120641. /**
  120642. * Block used to scale a vector by a float
  120643. */
  120644. export class ScaleBlock extends NodeMaterialBlock {
  120645. /**
  120646. * Creates a new ScaleBlock
  120647. * @param name defines the block name
  120648. */
  120649. constructor(name: string);
  120650. /**
  120651. * Gets the current class name
  120652. * @returns the class name
  120653. */
  120654. getClassName(): string;
  120655. /**
  120656. * Gets the input component
  120657. */
  120658. readonly input: NodeMaterialConnectionPoint;
  120659. /**
  120660. * Gets the factor input component
  120661. */
  120662. readonly factor: NodeMaterialConnectionPoint;
  120663. /**
  120664. * Gets the output component
  120665. */
  120666. readonly output: NodeMaterialConnectionPoint;
  120667. protected _buildBlock(state: NodeMaterialBuildState): this;
  120668. }
  120669. }
  120670. declare module BABYLON {
  120671. /**
  120672. * Block used to clamp a float
  120673. */
  120674. export class ClampBlock extends NodeMaterialBlock {
  120675. /** Gets or sets the minimum range */
  120676. minimum: number;
  120677. /** Gets or sets the maximum range */
  120678. maximum: number;
  120679. /**
  120680. * Creates a new ClampBlock
  120681. * @param name defines the block name
  120682. */
  120683. constructor(name: string);
  120684. /**
  120685. * Gets the current class name
  120686. * @returns the class name
  120687. */
  120688. getClassName(): string;
  120689. /**
  120690. * Gets the value input component
  120691. */
  120692. readonly value: NodeMaterialConnectionPoint;
  120693. /**
  120694. * Gets the output component
  120695. */
  120696. readonly output: NodeMaterialConnectionPoint;
  120697. protected _buildBlock(state: NodeMaterialBuildState): this;
  120698. protected _dumpPropertiesCode(): string;
  120699. serialize(): any;
  120700. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120701. }
  120702. }
  120703. declare module BABYLON {
  120704. /**
  120705. * Block used to apply a cross product between 2 vectors
  120706. */
  120707. export class CrossBlock extends NodeMaterialBlock {
  120708. /**
  120709. * Creates a new CrossBlock
  120710. * @param name defines the block name
  120711. */
  120712. constructor(name: string);
  120713. /**
  120714. * Gets the current class name
  120715. * @returns the class name
  120716. */
  120717. getClassName(): string;
  120718. /**
  120719. * Gets the left operand input component
  120720. */
  120721. readonly left: NodeMaterialConnectionPoint;
  120722. /**
  120723. * Gets the right operand input component
  120724. */
  120725. readonly right: NodeMaterialConnectionPoint;
  120726. /**
  120727. * Gets the output component
  120728. */
  120729. readonly output: NodeMaterialConnectionPoint;
  120730. protected _buildBlock(state: NodeMaterialBuildState): this;
  120731. }
  120732. }
  120733. declare module BABYLON {
  120734. /**
  120735. * Block used to apply a dot product between 2 vectors
  120736. */
  120737. export class DotBlock extends NodeMaterialBlock {
  120738. /**
  120739. * Creates a new DotBlock
  120740. * @param name defines the block name
  120741. */
  120742. constructor(name: string);
  120743. /**
  120744. * Gets the current class name
  120745. * @returns the class name
  120746. */
  120747. getClassName(): string;
  120748. /**
  120749. * Gets the left operand input component
  120750. */
  120751. readonly left: NodeMaterialConnectionPoint;
  120752. /**
  120753. * Gets the right operand input component
  120754. */
  120755. readonly right: NodeMaterialConnectionPoint;
  120756. /**
  120757. * Gets the output component
  120758. */
  120759. readonly output: NodeMaterialConnectionPoint;
  120760. protected _buildBlock(state: NodeMaterialBuildState): this;
  120761. }
  120762. }
  120763. declare module BABYLON {
  120764. /**
  120765. * Block used to remap a float from a range to a new one
  120766. */
  120767. export class RemapBlock extends NodeMaterialBlock {
  120768. /**
  120769. * Gets or sets the source range
  120770. */
  120771. sourceRange: Vector2;
  120772. /**
  120773. * Gets or sets the target range
  120774. */
  120775. targetRange: Vector2;
  120776. /**
  120777. * Creates a new RemapBlock
  120778. * @param name defines the block name
  120779. */
  120780. constructor(name: string);
  120781. /**
  120782. * Gets the current class name
  120783. * @returns the class name
  120784. */
  120785. getClassName(): string;
  120786. /**
  120787. * Gets the input component
  120788. */
  120789. readonly input: NodeMaterialConnectionPoint;
  120790. /**
  120791. * Gets the source min input component
  120792. */
  120793. readonly sourceMin: NodeMaterialConnectionPoint;
  120794. /**
  120795. * Gets the source max input component
  120796. */
  120797. readonly sourceMax: NodeMaterialConnectionPoint;
  120798. /**
  120799. * Gets the target min input component
  120800. */
  120801. readonly targetMin: NodeMaterialConnectionPoint;
  120802. /**
  120803. * Gets the target max input component
  120804. */
  120805. readonly targetMax: NodeMaterialConnectionPoint;
  120806. /**
  120807. * Gets the output component
  120808. */
  120809. readonly output: NodeMaterialConnectionPoint;
  120810. protected _buildBlock(state: NodeMaterialBuildState): this;
  120811. protected _dumpPropertiesCode(): string;
  120812. serialize(): any;
  120813. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120814. }
  120815. }
  120816. declare module BABYLON {
  120817. /**
  120818. * Block used to normalize a vector
  120819. */
  120820. export class NormalizeBlock extends NodeMaterialBlock {
  120821. /**
  120822. * Creates a new NormalizeBlock
  120823. * @param name defines the block name
  120824. */
  120825. constructor(name: string);
  120826. /**
  120827. * Gets the current class name
  120828. * @returns the class name
  120829. */
  120830. getClassName(): string;
  120831. /**
  120832. * Gets the input component
  120833. */
  120834. readonly input: NodeMaterialConnectionPoint;
  120835. /**
  120836. * Gets the output component
  120837. */
  120838. readonly output: NodeMaterialConnectionPoint;
  120839. protected _buildBlock(state: NodeMaterialBuildState): this;
  120840. }
  120841. }
  120842. declare module BABYLON {
  120843. /**
  120844. * Operations supported by the Trigonometry block
  120845. */
  120846. export enum TrigonometryBlockOperations {
  120847. /** Cos */
  120848. Cos = 0,
  120849. /** Sin */
  120850. Sin = 1,
  120851. /** Abs */
  120852. Abs = 2,
  120853. /** Exp */
  120854. Exp = 3,
  120855. /** Exp2 */
  120856. Exp2 = 4,
  120857. /** Round */
  120858. Round = 5,
  120859. /** Floor */
  120860. Floor = 6,
  120861. /** Ceiling */
  120862. Ceiling = 7,
  120863. /** Square root */
  120864. Sqrt = 8
  120865. }
  120866. /**
  120867. * Block used to apply trigonometry operation to floats
  120868. */
  120869. export class TrigonometryBlock extends NodeMaterialBlock {
  120870. /**
  120871. * Gets or sets the operation applied by the block
  120872. */
  120873. operation: TrigonometryBlockOperations;
  120874. /**
  120875. * Creates a new TrigonometryBlock
  120876. * @param name defines the block name
  120877. */
  120878. constructor(name: string);
  120879. /**
  120880. * Gets the current class name
  120881. * @returns the class name
  120882. */
  120883. getClassName(): string;
  120884. /**
  120885. * Gets the input component
  120886. */
  120887. readonly input: NodeMaterialConnectionPoint;
  120888. /**
  120889. * Gets the output component
  120890. */
  120891. readonly output: NodeMaterialConnectionPoint;
  120892. protected _buildBlock(state: NodeMaterialBuildState): this;
  120893. serialize(): any;
  120894. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120895. }
  120896. }
  120897. declare module BABYLON {
  120898. /**
  120899. * Block used to create a Color3/4 out of individual inputs (one for each component)
  120900. */
  120901. export class ColorMergerBlock extends NodeMaterialBlock {
  120902. /**
  120903. * Create a new ColorMergerBlock
  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 r component (input)
  120914. */
  120915. readonly r: NodeMaterialConnectionPoint;
  120916. /**
  120917. * Gets the g component (input)
  120918. */
  120919. readonly g: NodeMaterialConnectionPoint;
  120920. /**
  120921. * Gets the b component (input)
  120922. */
  120923. readonly b: NodeMaterialConnectionPoint;
  120924. /**
  120925. * Gets the a component (input)
  120926. */
  120927. readonly a: NodeMaterialConnectionPoint;
  120928. /**
  120929. * Gets the rgba component (output)
  120930. */
  120931. readonly rgba: NodeMaterialConnectionPoint;
  120932. /**
  120933. * Gets the rgb component (output)
  120934. */
  120935. readonly rgb: NodeMaterialConnectionPoint;
  120936. protected _buildBlock(state: NodeMaterialBuildState): this;
  120937. }
  120938. }
  120939. declare module BABYLON {
  120940. /**
  120941. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  120942. */
  120943. export class VectorMergerBlock extends NodeMaterialBlock {
  120944. /**
  120945. * Create a new VectorMergerBlock
  120946. * @param name defines the block name
  120947. */
  120948. constructor(name: string);
  120949. /**
  120950. * Gets the current class name
  120951. * @returns the class name
  120952. */
  120953. getClassName(): string;
  120954. /**
  120955. * Gets the x component (input)
  120956. */
  120957. readonly x: NodeMaterialConnectionPoint;
  120958. /**
  120959. * Gets the y component (input)
  120960. */
  120961. readonly y: NodeMaterialConnectionPoint;
  120962. /**
  120963. * Gets the z component (input)
  120964. */
  120965. readonly z: NodeMaterialConnectionPoint;
  120966. /**
  120967. * Gets the w component (input)
  120968. */
  120969. readonly w: NodeMaterialConnectionPoint;
  120970. /**
  120971. * Gets the xyzw component (output)
  120972. */
  120973. readonly xyzw: NodeMaterialConnectionPoint;
  120974. /**
  120975. * Gets the xyz component (output)
  120976. */
  120977. readonly xyz: NodeMaterialConnectionPoint;
  120978. /**
  120979. * Gets the xy component (output)
  120980. */
  120981. readonly xy: NodeMaterialConnectionPoint;
  120982. protected _buildBlock(state: NodeMaterialBuildState): this;
  120983. }
  120984. }
  120985. declare module BABYLON {
  120986. /**
  120987. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  120988. */
  120989. export class ColorSplitterBlock extends NodeMaterialBlock {
  120990. /**
  120991. * Create a new ColorSplitterBlock
  120992. * @param name defines the block name
  120993. */
  120994. constructor(name: string);
  120995. /**
  120996. * Gets the current class name
  120997. * @returns the class name
  120998. */
  120999. getClassName(): string;
  121000. /**
  121001. * Gets the rgba component (input)
  121002. */
  121003. readonly rgba: NodeMaterialConnectionPoint;
  121004. /**
  121005. * Gets the rgb component (input)
  121006. */
  121007. readonly rgbIn: NodeMaterialConnectionPoint;
  121008. /**
  121009. * Gets the rgb component (output)
  121010. */
  121011. readonly rgbOut: NodeMaterialConnectionPoint;
  121012. /**
  121013. * Gets the r component (output)
  121014. */
  121015. readonly r: NodeMaterialConnectionPoint;
  121016. /**
  121017. * Gets the g component (output)
  121018. */
  121019. readonly g: NodeMaterialConnectionPoint;
  121020. /**
  121021. * Gets the b component (output)
  121022. */
  121023. readonly b: NodeMaterialConnectionPoint;
  121024. /**
  121025. * Gets the a component (output)
  121026. */
  121027. readonly a: NodeMaterialConnectionPoint;
  121028. protected _inputRename(name: string): string;
  121029. protected _outputRename(name: string): string;
  121030. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121031. }
  121032. }
  121033. declare module BABYLON {
  121034. /**
  121035. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  121036. */
  121037. export class VectorSplitterBlock extends NodeMaterialBlock {
  121038. /**
  121039. * Create a new VectorSplitterBlock
  121040. * @param name defines the block name
  121041. */
  121042. constructor(name: string);
  121043. /**
  121044. * Gets the current class name
  121045. * @returns the class name
  121046. */
  121047. getClassName(): string;
  121048. /**
  121049. * Gets the xyzw component (input)
  121050. */
  121051. readonly xyzw: NodeMaterialConnectionPoint;
  121052. /**
  121053. * Gets the xyz component (input)
  121054. */
  121055. readonly xyzIn: NodeMaterialConnectionPoint;
  121056. /**
  121057. * Gets the xy component (input)
  121058. */
  121059. readonly xyIn: NodeMaterialConnectionPoint;
  121060. /**
  121061. * Gets the xyz component (output)
  121062. */
  121063. readonly xyzOut: NodeMaterialConnectionPoint;
  121064. /**
  121065. * Gets the xy component (output)
  121066. */
  121067. readonly xyOut: NodeMaterialConnectionPoint;
  121068. /**
  121069. * Gets the x component (output)
  121070. */
  121071. readonly x: NodeMaterialConnectionPoint;
  121072. /**
  121073. * Gets the y component (output)
  121074. */
  121075. readonly y: NodeMaterialConnectionPoint;
  121076. /**
  121077. * Gets the z component (output)
  121078. */
  121079. readonly z: NodeMaterialConnectionPoint;
  121080. /**
  121081. * Gets the w component (output)
  121082. */
  121083. readonly w: NodeMaterialConnectionPoint;
  121084. protected _inputRename(name: string): string;
  121085. protected _outputRename(name: string): string;
  121086. protected _buildBlock(state: NodeMaterialBuildState): this;
  121087. }
  121088. }
  121089. declare module BABYLON {
  121090. /**
  121091. * Block used to lerp 2 values
  121092. */
  121093. export class LerpBlock extends NodeMaterialBlock {
  121094. /**
  121095. * Creates a new LerpBlock
  121096. * @param name defines the block name
  121097. */
  121098. constructor(name: string);
  121099. /**
  121100. * Gets the current class name
  121101. * @returns the class name
  121102. */
  121103. getClassName(): string;
  121104. /**
  121105. * Gets the left operand input component
  121106. */
  121107. readonly left: NodeMaterialConnectionPoint;
  121108. /**
  121109. * Gets the right operand input component
  121110. */
  121111. readonly right: NodeMaterialConnectionPoint;
  121112. /**
  121113. * Gets the gradient operand input component
  121114. */
  121115. readonly gradient: NodeMaterialConnectionPoint;
  121116. /**
  121117. * Gets the output component
  121118. */
  121119. readonly output: NodeMaterialConnectionPoint;
  121120. protected _buildBlock(state: NodeMaterialBuildState): this;
  121121. }
  121122. }
  121123. declare module BABYLON {
  121124. /**
  121125. * Block used to divide 2 vectors
  121126. */
  121127. export class DivideBlock extends NodeMaterialBlock {
  121128. /**
  121129. * Creates a new DivideBlock
  121130. * @param name defines the block name
  121131. */
  121132. constructor(name: string);
  121133. /**
  121134. * Gets the current class name
  121135. * @returns the class name
  121136. */
  121137. getClassName(): string;
  121138. /**
  121139. * Gets the left operand input component
  121140. */
  121141. readonly left: NodeMaterialConnectionPoint;
  121142. /**
  121143. * Gets the right operand input component
  121144. */
  121145. readonly right: NodeMaterialConnectionPoint;
  121146. /**
  121147. * Gets the output component
  121148. */
  121149. readonly output: NodeMaterialConnectionPoint;
  121150. protected _buildBlock(state: NodeMaterialBuildState): this;
  121151. }
  121152. }
  121153. declare module BABYLON {
  121154. /**
  121155. * Block used to subtract 2 vectors
  121156. */
  121157. export class SubtractBlock extends NodeMaterialBlock {
  121158. /**
  121159. * Creates a new SubtractBlock
  121160. * @param name defines the block name
  121161. */
  121162. constructor(name: string);
  121163. /**
  121164. * Gets the current class name
  121165. * @returns the class name
  121166. */
  121167. getClassName(): string;
  121168. /**
  121169. * Gets the left operand input component
  121170. */
  121171. readonly left: NodeMaterialConnectionPoint;
  121172. /**
  121173. * Gets the right operand input component
  121174. */
  121175. readonly right: NodeMaterialConnectionPoint;
  121176. /**
  121177. * Gets the output component
  121178. */
  121179. readonly output: NodeMaterialConnectionPoint;
  121180. protected _buildBlock(state: NodeMaterialBuildState): this;
  121181. }
  121182. }
  121183. declare module BABYLON {
  121184. /**
  121185. * Block used to step a value
  121186. */
  121187. export class StepBlock extends NodeMaterialBlock {
  121188. /**
  121189. * Creates a new AddBlock
  121190. * @param name defines the block name
  121191. */
  121192. constructor(name: string);
  121193. /**
  121194. * Gets the current class name
  121195. * @returns the class name
  121196. */
  121197. getClassName(): string;
  121198. /**
  121199. * Gets the value operand input component
  121200. */
  121201. readonly value: NodeMaterialConnectionPoint;
  121202. /**
  121203. * Gets the edge operand input component
  121204. */
  121205. readonly edge: NodeMaterialConnectionPoint;
  121206. /**
  121207. * Gets the output component
  121208. */
  121209. readonly output: NodeMaterialConnectionPoint;
  121210. protected _buildBlock(state: NodeMaterialBuildState): this;
  121211. }
  121212. }
  121213. declare module BABYLON {
  121214. /**
  121215. * Block used to get the opposite (1 - x) of a value
  121216. */
  121217. export class OneMinusBlock extends NodeMaterialBlock {
  121218. /**
  121219. * Creates a new OneMinusBlock
  121220. * @param name defines the block name
  121221. */
  121222. constructor(name: string);
  121223. /**
  121224. * Gets the current class name
  121225. * @returns the class name
  121226. */
  121227. getClassName(): string;
  121228. /**
  121229. * Gets the input component
  121230. */
  121231. readonly input: NodeMaterialConnectionPoint;
  121232. /**
  121233. * Gets the output component
  121234. */
  121235. readonly output: NodeMaterialConnectionPoint;
  121236. protected _buildBlock(state: NodeMaterialBuildState): this;
  121237. }
  121238. }
  121239. declare module BABYLON {
  121240. /**
  121241. * Block used to get the view direction
  121242. */
  121243. export class ViewDirectionBlock extends NodeMaterialBlock {
  121244. /**
  121245. * Creates a new ViewDirectionBlock
  121246. * @param name defines the block name
  121247. */
  121248. constructor(name: string);
  121249. /**
  121250. * Gets the current class name
  121251. * @returns the class name
  121252. */
  121253. getClassName(): string;
  121254. /**
  121255. * Gets the world position component
  121256. */
  121257. readonly worldPosition: NodeMaterialConnectionPoint;
  121258. /**
  121259. * Gets the camera position component
  121260. */
  121261. readonly cameraPosition: NodeMaterialConnectionPoint;
  121262. /**
  121263. * Gets the output component
  121264. */
  121265. readonly output: NodeMaterialConnectionPoint;
  121266. autoConfigure(material: NodeMaterial): void;
  121267. protected _buildBlock(state: NodeMaterialBuildState): this;
  121268. }
  121269. }
  121270. declare module BABYLON {
  121271. /**
  121272. * Block used to compute fresnel value
  121273. */
  121274. export class FresnelBlock extends NodeMaterialBlock {
  121275. /**
  121276. * Create a new FresnelBlock
  121277. * @param name defines the block name
  121278. */
  121279. constructor(name: string);
  121280. /**
  121281. * Gets the current class name
  121282. * @returns the class name
  121283. */
  121284. getClassName(): string;
  121285. /**
  121286. * Gets the world normal input component
  121287. */
  121288. readonly worldNormal: NodeMaterialConnectionPoint;
  121289. /**
  121290. * Gets the view direction input component
  121291. */
  121292. readonly viewDirection: NodeMaterialConnectionPoint;
  121293. /**
  121294. * Gets the bias input component
  121295. */
  121296. readonly bias: NodeMaterialConnectionPoint;
  121297. /**
  121298. * Gets the camera (or eye) position component
  121299. */
  121300. readonly power: NodeMaterialConnectionPoint;
  121301. /**
  121302. * Gets the fresnel output component
  121303. */
  121304. readonly fresnel: NodeMaterialConnectionPoint;
  121305. autoConfigure(material: NodeMaterial): void;
  121306. protected _buildBlock(state: NodeMaterialBuildState): this;
  121307. }
  121308. }
  121309. declare module BABYLON {
  121310. /**
  121311. * Block used to get the max of 2 values
  121312. */
  121313. export class MaxBlock extends NodeMaterialBlock {
  121314. /**
  121315. * Creates a new MaxBlock
  121316. * @param name defines the block name
  121317. */
  121318. constructor(name: string);
  121319. /**
  121320. * Gets the current class name
  121321. * @returns the class name
  121322. */
  121323. getClassName(): string;
  121324. /**
  121325. * Gets the left operand input component
  121326. */
  121327. readonly left: NodeMaterialConnectionPoint;
  121328. /**
  121329. * Gets the right operand input component
  121330. */
  121331. readonly right: NodeMaterialConnectionPoint;
  121332. /**
  121333. * Gets the output component
  121334. */
  121335. readonly output: NodeMaterialConnectionPoint;
  121336. protected _buildBlock(state: NodeMaterialBuildState): this;
  121337. }
  121338. }
  121339. declare module BABYLON {
  121340. /**
  121341. * Block used to get the min of 2 values
  121342. */
  121343. export class MinBlock extends NodeMaterialBlock {
  121344. /**
  121345. * Creates a new MinBlock
  121346. * @param name defines the block name
  121347. */
  121348. constructor(name: string);
  121349. /**
  121350. * Gets the current class name
  121351. * @returns the class name
  121352. */
  121353. getClassName(): string;
  121354. /**
  121355. * Gets the left operand input component
  121356. */
  121357. readonly left: NodeMaterialConnectionPoint;
  121358. /**
  121359. * Gets the right operand input component
  121360. */
  121361. readonly right: NodeMaterialConnectionPoint;
  121362. /**
  121363. * Gets the output component
  121364. */
  121365. readonly output: NodeMaterialConnectionPoint;
  121366. protected _buildBlock(state: NodeMaterialBuildState): this;
  121367. }
  121368. }
  121369. declare module BABYLON {
  121370. /**
  121371. * Block used to get the distance between 2 values
  121372. */
  121373. export class DistanceBlock extends NodeMaterialBlock {
  121374. /**
  121375. * Creates a new DistanceBlock
  121376. * @param name defines the block name
  121377. */
  121378. constructor(name: string);
  121379. /**
  121380. * Gets the current class name
  121381. * @returns the class name
  121382. */
  121383. getClassName(): string;
  121384. /**
  121385. * Gets the left operand input component
  121386. */
  121387. readonly left: NodeMaterialConnectionPoint;
  121388. /**
  121389. * Gets the right operand input component
  121390. */
  121391. readonly right: NodeMaterialConnectionPoint;
  121392. /**
  121393. * Gets the output component
  121394. */
  121395. readonly output: NodeMaterialConnectionPoint;
  121396. protected _buildBlock(state: NodeMaterialBuildState): this;
  121397. }
  121398. }
  121399. declare module BABYLON {
  121400. /**
  121401. * Block used to get the length of a vector
  121402. */
  121403. export class LengthBlock extends NodeMaterialBlock {
  121404. /**
  121405. * Creates a new LengthBlock
  121406. * @param name defines the block name
  121407. */
  121408. constructor(name: string);
  121409. /**
  121410. * Gets the current class name
  121411. * @returns the class name
  121412. */
  121413. getClassName(): string;
  121414. /**
  121415. * Gets the value input component
  121416. */
  121417. readonly value: NodeMaterialConnectionPoint;
  121418. /**
  121419. * Gets the output component
  121420. */
  121421. readonly output: NodeMaterialConnectionPoint;
  121422. protected _buildBlock(state: NodeMaterialBuildState): this;
  121423. }
  121424. }
  121425. declare module BABYLON {
  121426. /**
  121427. * Block used to get negative version of a value (i.e. x * -1)
  121428. */
  121429. export class NegateBlock extends NodeMaterialBlock {
  121430. /**
  121431. * Creates a new NegateBlock
  121432. * @param name defines the block name
  121433. */
  121434. constructor(name: string);
  121435. /**
  121436. * Gets the current class name
  121437. * @returns the class name
  121438. */
  121439. getClassName(): string;
  121440. /**
  121441. * Gets the value input component
  121442. */
  121443. readonly value: NodeMaterialConnectionPoint;
  121444. /**
  121445. * Gets the output component
  121446. */
  121447. readonly output: NodeMaterialConnectionPoint;
  121448. protected _buildBlock(state: NodeMaterialBuildState): this;
  121449. }
  121450. }
  121451. declare module BABYLON {
  121452. /**
  121453. * Block used to get the value of the first parameter raised to the power of the second
  121454. */
  121455. export class PowBlock extends NodeMaterialBlock {
  121456. /**
  121457. * Creates a new PowBlock
  121458. * @param name defines the block name
  121459. */
  121460. constructor(name: string);
  121461. /**
  121462. * Gets the current class name
  121463. * @returns the class name
  121464. */
  121465. getClassName(): string;
  121466. /**
  121467. * Gets the value operand input component
  121468. */
  121469. readonly value: NodeMaterialConnectionPoint;
  121470. /**
  121471. * Gets the power operand input component
  121472. */
  121473. readonly power: NodeMaterialConnectionPoint;
  121474. /**
  121475. * Gets the output component
  121476. */
  121477. readonly output: NodeMaterialConnectionPoint;
  121478. protected _buildBlock(state: NodeMaterialBuildState): this;
  121479. }
  121480. }
  121481. declare module BABYLON {
  121482. /**
  121483. * Block used to get a random number
  121484. */
  121485. export class RandomNumberBlock extends NodeMaterialBlock {
  121486. /**
  121487. * Creates a new RandomNumberBlock
  121488. * @param name defines the block name
  121489. */
  121490. constructor(name: string);
  121491. /**
  121492. * Gets the current class name
  121493. * @returns the class name
  121494. */
  121495. getClassName(): string;
  121496. /**
  121497. * Gets the seed input component
  121498. */
  121499. readonly seed: NodeMaterialConnectionPoint;
  121500. /**
  121501. * Gets the output component
  121502. */
  121503. readonly output: NodeMaterialConnectionPoint;
  121504. protected _buildBlock(state: NodeMaterialBuildState): this;
  121505. }
  121506. }
  121507. declare module BABYLON {
  121508. /**
  121509. * Effect Render Options
  121510. */
  121511. export interface IEffectRendererOptions {
  121512. /**
  121513. * Defines the vertices positions.
  121514. */
  121515. positions?: number[];
  121516. /**
  121517. * Defines the indices.
  121518. */
  121519. indices?: number[];
  121520. }
  121521. /**
  121522. * Helper class to render one or more effects
  121523. */
  121524. export class EffectRenderer {
  121525. private engine;
  121526. private static _DefaultOptions;
  121527. private _vertexBuffers;
  121528. private _indexBuffer;
  121529. private _ringBufferIndex;
  121530. private _ringScreenBuffer;
  121531. private _fullscreenViewport;
  121532. private _getNextFrameBuffer;
  121533. /**
  121534. * Creates an effect renderer
  121535. * @param engine the engine to use for rendering
  121536. * @param options defines the options of the effect renderer
  121537. */
  121538. constructor(engine: Engine, options?: IEffectRendererOptions);
  121539. /**
  121540. * Sets the current viewport in normalized coordinates 0-1
  121541. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  121542. */
  121543. setViewport(viewport?: Viewport): void;
  121544. /**
  121545. * Binds the embedded attributes buffer to the effect.
  121546. * @param effect Defines the effect to bind the attributes for
  121547. */
  121548. bindBuffers(effect: Effect): void;
  121549. /**
  121550. * Sets the current effect wrapper to use during draw.
  121551. * The effect needs to be ready before calling this api.
  121552. * This also sets the default full screen position attribute.
  121553. * @param effectWrapper Defines the effect to draw with
  121554. */
  121555. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  121556. /**
  121557. * Draws a full screen quad.
  121558. */
  121559. draw(): void;
  121560. /**
  121561. * renders one or more effects to a specified texture
  121562. * @param effectWrappers list of effects to renderer
  121563. * @param outputTexture texture to draw to, if null it will render to the screen
  121564. */
  121565. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  121566. /**
  121567. * Disposes of the effect renderer
  121568. */
  121569. dispose(): void;
  121570. }
  121571. /**
  121572. * Options to create an EffectWrapper
  121573. */
  121574. interface EffectWrapperCreationOptions {
  121575. /**
  121576. * Engine to use to create the effect
  121577. */
  121578. engine: Engine;
  121579. /**
  121580. * Fragment shader for the effect
  121581. */
  121582. fragmentShader: string;
  121583. /**
  121584. * Vertex shader for the effect
  121585. */
  121586. vertexShader?: string;
  121587. /**
  121588. * Attributes to use in the shader
  121589. */
  121590. attributeNames?: Array<string>;
  121591. /**
  121592. * Uniforms to use in the shader
  121593. */
  121594. uniformNames?: Array<string>;
  121595. /**
  121596. * Texture sampler names to use in the shader
  121597. */
  121598. samplerNames?: Array<string>;
  121599. /**
  121600. * The friendly name of the effect displayed in Spector.
  121601. */
  121602. name?: string;
  121603. }
  121604. /**
  121605. * Wraps an effect to be used for rendering
  121606. */
  121607. export class EffectWrapper {
  121608. /**
  121609. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  121610. */
  121611. onApplyObservable: Observable<{}>;
  121612. /**
  121613. * The underlying effect
  121614. */
  121615. effect: Effect;
  121616. /**
  121617. * Creates an effect to be renderer
  121618. * @param creationOptions options to create the effect
  121619. */
  121620. constructor(creationOptions: EffectWrapperCreationOptions);
  121621. /**
  121622. * Disposes of the effect wrapper
  121623. */
  121624. dispose(): void;
  121625. }
  121626. }
  121627. declare module BABYLON {
  121628. /**
  121629. * Helper class to push actions to a pool of workers.
  121630. */
  121631. export class WorkerPool implements IDisposable {
  121632. private _workerInfos;
  121633. private _pendingActions;
  121634. /**
  121635. * Constructor
  121636. * @param workers Array of workers to use for actions
  121637. */
  121638. constructor(workers: Array<Worker>);
  121639. /**
  121640. * Terminates all workers and clears any pending actions.
  121641. */
  121642. dispose(): void;
  121643. /**
  121644. * Pushes an action to the worker pool. If all the workers are active, the action will be
  121645. * pended until a worker has completed its action.
  121646. * @param action The action to perform. Call onComplete when the action is complete.
  121647. */
  121648. push(action: (worker: Worker, onComplete: () => void) => void): void;
  121649. private _execute;
  121650. }
  121651. }
  121652. declare module BABYLON {
  121653. /**
  121654. * Configuration for Draco compression
  121655. */
  121656. export interface IDracoCompressionConfiguration {
  121657. /**
  121658. * Configuration for the decoder.
  121659. */
  121660. decoder: {
  121661. /**
  121662. * The url to the WebAssembly module.
  121663. */
  121664. wasmUrl?: string;
  121665. /**
  121666. * The url to the WebAssembly binary.
  121667. */
  121668. wasmBinaryUrl?: string;
  121669. /**
  121670. * The url to the fallback JavaScript module.
  121671. */
  121672. fallbackUrl?: string;
  121673. };
  121674. }
  121675. /**
  121676. * Draco compression (https://google.github.io/draco/)
  121677. *
  121678. * This class wraps the Draco module.
  121679. *
  121680. * **Encoder**
  121681. *
  121682. * The encoder is not currently implemented.
  121683. *
  121684. * **Decoder**
  121685. *
  121686. * 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.
  121687. *
  121688. * To update the configuration, use the following code:
  121689. * ```javascript
  121690. * DracoCompression.Configuration = {
  121691. * decoder: {
  121692. * wasmUrl: "<url to the WebAssembly library>",
  121693. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  121694. * fallbackUrl: "<url to the fallback JavaScript library>",
  121695. * }
  121696. * };
  121697. * ```
  121698. *
  121699. * 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.
  121700. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  121701. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  121702. *
  121703. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  121704. * ```javascript
  121705. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  121706. * ```
  121707. *
  121708. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  121709. */
  121710. export class DracoCompression implements IDisposable {
  121711. private _workerPoolPromise?;
  121712. private _decoderModulePromise?;
  121713. /**
  121714. * The configuration. Defaults to the following urls:
  121715. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  121716. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  121717. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  121718. */
  121719. static Configuration: IDracoCompressionConfiguration;
  121720. /**
  121721. * Returns true if the decoder configuration is available.
  121722. */
  121723. static readonly DecoderAvailable: boolean;
  121724. /**
  121725. * Default number of workers to create when creating the draco compression object.
  121726. */
  121727. static DefaultNumWorkers: number;
  121728. private static GetDefaultNumWorkers;
  121729. private static _Default;
  121730. /**
  121731. * Default instance for the draco compression object.
  121732. */
  121733. static readonly Default: DracoCompression;
  121734. /**
  121735. * Constructor
  121736. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  121737. */
  121738. constructor(numWorkers?: number);
  121739. /**
  121740. * Stop all async operations and release resources.
  121741. */
  121742. dispose(): void;
  121743. /**
  121744. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  121745. * @returns a promise that resolves when ready
  121746. */
  121747. whenReadyAsync(): Promise<void>;
  121748. /**
  121749. * Decode Draco compressed mesh data to vertex data.
  121750. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  121751. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  121752. * @returns A promise that resolves with the decoded vertex data
  121753. */
  121754. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  121755. [kind: string]: number;
  121756. }): Promise<VertexData>;
  121757. }
  121758. }
  121759. declare module BABYLON {
  121760. /**
  121761. * Class for building Constructive Solid Geometry
  121762. */
  121763. export class CSG {
  121764. private polygons;
  121765. /**
  121766. * The world matrix
  121767. */
  121768. matrix: Matrix;
  121769. /**
  121770. * Stores the position
  121771. */
  121772. position: Vector3;
  121773. /**
  121774. * Stores the rotation
  121775. */
  121776. rotation: Vector3;
  121777. /**
  121778. * Stores the rotation quaternion
  121779. */
  121780. rotationQuaternion: Nullable<Quaternion>;
  121781. /**
  121782. * Stores the scaling vector
  121783. */
  121784. scaling: Vector3;
  121785. /**
  121786. * Convert the Mesh to CSG
  121787. * @param mesh The Mesh to convert to CSG
  121788. * @returns A new CSG from the Mesh
  121789. */
  121790. static FromMesh(mesh: Mesh): CSG;
  121791. /**
  121792. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  121793. * @param polygons Polygons used to construct a CSG solid
  121794. */
  121795. private static FromPolygons;
  121796. /**
  121797. * Clones, or makes a deep copy, of the CSG
  121798. * @returns A new CSG
  121799. */
  121800. clone(): CSG;
  121801. /**
  121802. * Unions this CSG with another CSG
  121803. * @param csg The CSG to union against this CSG
  121804. * @returns The unioned CSG
  121805. */
  121806. union(csg: CSG): CSG;
  121807. /**
  121808. * Unions this CSG with another CSG in place
  121809. * @param csg The CSG to union against this CSG
  121810. */
  121811. unionInPlace(csg: CSG): void;
  121812. /**
  121813. * Subtracts this CSG with another CSG
  121814. * @param csg The CSG to subtract against this CSG
  121815. * @returns A new CSG
  121816. */
  121817. subtract(csg: CSG): CSG;
  121818. /**
  121819. * Subtracts this CSG with another CSG in place
  121820. * @param csg The CSG to subtact against this CSG
  121821. */
  121822. subtractInPlace(csg: CSG): void;
  121823. /**
  121824. * Intersect this CSG with another CSG
  121825. * @param csg The CSG to intersect against this CSG
  121826. * @returns A new CSG
  121827. */
  121828. intersect(csg: CSG): CSG;
  121829. /**
  121830. * Intersects this CSG with another CSG in place
  121831. * @param csg The CSG to intersect against this CSG
  121832. */
  121833. intersectInPlace(csg: CSG): void;
  121834. /**
  121835. * Return a new CSG solid with solid and empty space switched. This solid is
  121836. * not modified.
  121837. * @returns A new CSG solid with solid and empty space switched
  121838. */
  121839. inverse(): CSG;
  121840. /**
  121841. * Inverses the CSG in place
  121842. */
  121843. inverseInPlace(): void;
  121844. /**
  121845. * This is used to keep meshes transformations so they can be restored
  121846. * when we build back a Babylon Mesh
  121847. * NB : All CSG operations are performed in world coordinates
  121848. * @param csg The CSG to copy the transform attributes from
  121849. * @returns This CSG
  121850. */
  121851. copyTransformAttributes(csg: CSG): CSG;
  121852. /**
  121853. * Build Raw mesh from CSG
  121854. * Coordinates here are in world space
  121855. * @param name The name of the mesh geometry
  121856. * @param scene The Scene
  121857. * @param keepSubMeshes Specifies if the submeshes should be kept
  121858. * @returns A new Mesh
  121859. */
  121860. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  121861. /**
  121862. * Build Mesh from CSG taking material and transforms into account
  121863. * @param name The name of the Mesh
  121864. * @param material The material of the Mesh
  121865. * @param scene The Scene
  121866. * @param keepSubMeshes Specifies if submeshes should be kept
  121867. * @returns The new Mesh
  121868. */
  121869. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  121870. }
  121871. }
  121872. declare module BABYLON {
  121873. /**
  121874. * Class used to create a trail following a mesh
  121875. */
  121876. export class TrailMesh extends Mesh {
  121877. private _generator;
  121878. private _autoStart;
  121879. private _running;
  121880. private _diameter;
  121881. private _length;
  121882. private _sectionPolygonPointsCount;
  121883. private _sectionVectors;
  121884. private _sectionNormalVectors;
  121885. private _beforeRenderObserver;
  121886. /**
  121887. * @constructor
  121888. * @param name The value used by scene.getMeshByName() to do a lookup.
  121889. * @param generator The mesh to generate a trail.
  121890. * @param scene The scene to add this mesh to.
  121891. * @param diameter Diameter of trailing mesh. Default is 1.
  121892. * @param length Length of trailing mesh. Default is 60.
  121893. * @param autoStart Automatically start trailing mesh. Default true.
  121894. */
  121895. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  121896. /**
  121897. * "TrailMesh"
  121898. * @returns "TrailMesh"
  121899. */
  121900. getClassName(): string;
  121901. private _createMesh;
  121902. /**
  121903. * Start trailing mesh.
  121904. */
  121905. start(): void;
  121906. /**
  121907. * Stop trailing mesh.
  121908. */
  121909. stop(): void;
  121910. /**
  121911. * Update trailing mesh geometry.
  121912. */
  121913. update(): void;
  121914. /**
  121915. * Returns a new TrailMesh object.
  121916. * @param name is a string, the name given to the new mesh
  121917. * @param newGenerator use new generator object for cloned trail mesh
  121918. * @returns a new mesh
  121919. */
  121920. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  121921. /**
  121922. * Serializes this trail mesh
  121923. * @param serializationObject object to write serialization to
  121924. */
  121925. serialize(serializationObject: any): void;
  121926. /**
  121927. * Parses a serialized trail mesh
  121928. * @param parsedMesh the serialized mesh
  121929. * @param scene the scene to create the trail mesh in
  121930. * @returns the created trail mesh
  121931. */
  121932. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  121933. }
  121934. }
  121935. declare module BABYLON {
  121936. /**
  121937. * Class containing static functions to help procedurally build meshes
  121938. */
  121939. export class TiledBoxBuilder {
  121940. /**
  121941. * Creates a box mesh
  121942. * 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)
  121943. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121944. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121945. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121947. * @param name defines the name of the mesh
  121948. * @param options defines the options used to create the mesh
  121949. * @param scene defines the hosting scene
  121950. * @returns the box mesh
  121951. */
  121952. static CreateTiledBox(name: string, options: {
  121953. pattern?: number;
  121954. width?: number;
  121955. height?: number;
  121956. depth?: number;
  121957. tileSize?: number;
  121958. tileWidth?: number;
  121959. tileHeight?: number;
  121960. alignHorizontal?: number;
  121961. alignVertical?: number;
  121962. faceUV?: Vector4[];
  121963. faceColors?: Color4[];
  121964. sideOrientation?: number;
  121965. updatable?: boolean;
  121966. }, scene?: Nullable<Scene>): Mesh;
  121967. }
  121968. }
  121969. declare module BABYLON {
  121970. /**
  121971. * Class containing static functions to help procedurally build meshes
  121972. */
  121973. export class TorusKnotBuilder {
  121974. /**
  121975. * Creates a torus knot mesh
  121976. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  121977. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  121978. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  121979. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  121980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121981. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121983. * @param name defines the name of the mesh
  121984. * @param options defines the options used to create the mesh
  121985. * @param scene defines the hosting scene
  121986. * @returns the torus knot mesh
  121987. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  121988. */
  121989. static CreateTorusKnot(name: string, options: {
  121990. radius?: number;
  121991. tube?: number;
  121992. radialSegments?: number;
  121993. tubularSegments?: number;
  121994. p?: number;
  121995. q?: number;
  121996. updatable?: boolean;
  121997. sideOrientation?: number;
  121998. frontUVs?: Vector4;
  121999. backUVs?: Vector4;
  122000. }, scene: any): Mesh;
  122001. }
  122002. }
  122003. declare module BABYLON {
  122004. /**
  122005. * Polygon
  122006. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  122007. */
  122008. export class Polygon {
  122009. /**
  122010. * Creates a rectangle
  122011. * @param xmin bottom X coord
  122012. * @param ymin bottom Y coord
  122013. * @param xmax top X coord
  122014. * @param ymax top Y coord
  122015. * @returns points that make the resulting rectation
  122016. */
  122017. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  122018. /**
  122019. * Creates a circle
  122020. * @param radius radius of circle
  122021. * @param cx scale in x
  122022. * @param cy scale in y
  122023. * @param numberOfSides number of sides that make up the circle
  122024. * @returns points that make the resulting circle
  122025. */
  122026. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  122027. /**
  122028. * Creates a polygon from input string
  122029. * @param input Input polygon data
  122030. * @returns the parsed points
  122031. */
  122032. static Parse(input: string): Vector2[];
  122033. /**
  122034. * Starts building a polygon from x and y coordinates
  122035. * @param x x coordinate
  122036. * @param y y coordinate
  122037. * @returns the started path2
  122038. */
  122039. static StartingAt(x: number, y: number): Path2;
  122040. }
  122041. /**
  122042. * Builds a polygon
  122043. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  122044. */
  122045. export class PolygonMeshBuilder {
  122046. private _points;
  122047. private _outlinepoints;
  122048. private _holes;
  122049. private _name;
  122050. private _scene;
  122051. private _epoints;
  122052. private _eholes;
  122053. private _addToepoint;
  122054. /**
  122055. * Babylon reference to the earcut plugin.
  122056. */
  122057. bjsEarcut: any;
  122058. /**
  122059. * Creates a PolygonMeshBuilder
  122060. * @param name name of the builder
  122061. * @param contours Path of the polygon
  122062. * @param scene scene to add to when creating the mesh
  122063. * @param earcutInjection can be used to inject your own earcut reference
  122064. */
  122065. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  122066. /**
  122067. * Adds a whole within the polygon
  122068. * @param hole Array of points defining the hole
  122069. * @returns this
  122070. */
  122071. addHole(hole: Vector2[]): PolygonMeshBuilder;
  122072. /**
  122073. * Creates the polygon
  122074. * @param updatable If the mesh should be updatable
  122075. * @param depth The depth of the mesh created
  122076. * @returns the created mesh
  122077. */
  122078. build(updatable?: boolean, depth?: number): Mesh;
  122079. /**
  122080. * Creates the polygon
  122081. * @param depth The depth of the mesh created
  122082. * @returns the created VertexData
  122083. */
  122084. buildVertexData(depth?: number): VertexData;
  122085. /**
  122086. * Adds a side to the polygon
  122087. * @param positions points that make the polygon
  122088. * @param normals normals of the polygon
  122089. * @param uvs uvs of the polygon
  122090. * @param indices indices of the polygon
  122091. * @param bounds bounds of the polygon
  122092. * @param points points of the polygon
  122093. * @param depth depth of the polygon
  122094. * @param flip flip of the polygon
  122095. */
  122096. private addSide;
  122097. }
  122098. }
  122099. declare module BABYLON {
  122100. /**
  122101. * Class containing static functions to help procedurally build meshes
  122102. */
  122103. export class PolygonBuilder {
  122104. /**
  122105. * Creates a polygon mesh
  122106. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  122107. * * 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
  122108. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122110. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  122111. * * Remember you can only change the shape positions, not their number when updating a polygon
  122112. * @param name defines the name of the mesh
  122113. * @param options defines the options used to create the mesh
  122114. * @param scene defines the hosting scene
  122115. * @param earcutInjection can be used to inject your own earcut reference
  122116. * @returns the polygon mesh
  122117. */
  122118. static CreatePolygon(name: string, options: {
  122119. shape: Vector3[];
  122120. holes?: Vector3[][];
  122121. depth?: number;
  122122. faceUV?: Vector4[];
  122123. faceColors?: Color4[];
  122124. updatable?: boolean;
  122125. sideOrientation?: number;
  122126. frontUVs?: Vector4;
  122127. backUVs?: Vector4;
  122128. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122129. /**
  122130. * Creates an extruded polygon mesh, with depth in the Y direction.
  122131. * * 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)
  122132. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122133. * @param name defines the name of the mesh
  122134. * @param options defines the options used to create the mesh
  122135. * @param scene defines the hosting scene
  122136. * @param earcutInjection can be used to inject your own earcut reference
  122137. * @returns the polygon mesh
  122138. */
  122139. static ExtrudePolygon(name: string, options: {
  122140. shape: Vector3[];
  122141. holes?: Vector3[][];
  122142. depth?: number;
  122143. faceUV?: Vector4[];
  122144. faceColors?: Color4[];
  122145. updatable?: boolean;
  122146. sideOrientation?: number;
  122147. frontUVs?: Vector4;
  122148. backUVs?: Vector4;
  122149. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122150. }
  122151. }
  122152. declare module BABYLON {
  122153. /**
  122154. * Class containing static functions to help procedurally build meshes
  122155. */
  122156. export class LatheBuilder {
  122157. /**
  122158. * Creates lathe mesh.
  122159. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  122160. * * 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
  122161. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  122162. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  122163. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  122164. * * 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
  122165. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  122166. * * 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
  122167. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122168. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122169. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122171. * @param name defines the name of the mesh
  122172. * @param options defines the options used to create the mesh
  122173. * @param scene defines the hosting scene
  122174. * @returns the lathe mesh
  122175. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  122176. */
  122177. static CreateLathe(name: string, options: {
  122178. shape: Vector3[];
  122179. radius?: number;
  122180. tessellation?: number;
  122181. clip?: number;
  122182. arc?: number;
  122183. closed?: boolean;
  122184. updatable?: boolean;
  122185. sideOrientation?: number;
  122186. frontUVs?: Vector4;
  122187. backUVs?: Vector4;
  122188. cap?: number;
  122189. invertUV?: boolean;
  122190. }, scene?: Nullable<Scene>): Mesh;
  122191. }
  122192. }
  122193. declare module BABYLON {
  122194. /**
  122195. * Class containing static functions to help procedurally build meshes
  122196. */
  122197. export class TiledPlaneBuilder {
  122198. /**
  122199. * Creates a tiled plane mesh
  122200. * * The parameter `pattern` will, depending on value, do nothing or
  122201. * * * flip (reflect about central vertical) alternate tiles across and up
  122202. * * * flip every tile on alternate rows
  122203. * * * rotate (180 degs) alternate tiles across and up
  122204. * * * rotate every tile on alternate rows
  122205. * * * flip and rotate alternate tiles across and up
  122206. * * * flip and rotate every tile on alternate rows
  122207. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  122208. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  122209. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122210. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122211. * * 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)
  122212. * * 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)
  122213. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  122214. * @param name defines the name of the mesh
  122215. * @param options defines the options used to create the mesh
  122216. * @param scene defines the hosting scene
  122217. * @returns the box mesh
  122218. */
  122219. static CreateTiledPlane(name: string, options: {
  122220. pattern?: number;
  122221. tileSize?: number;
  122222. tileWidth?: number;
  122223. tileHeight?: number;
  122224. size?: number;
  122225. width?: number;
  122226. height?: number;
  122227. alignHorizontal?: number;
  122228. alignVertical?: number;
  122229. sideOrientation?: number;
  122230. frontUVs?: Vector4;
  122231. backUVs?: Vector4;
  122232. updatable?: boolean;
  122233. }, scene?: Nullable<Scene>): Mesh;
  122234. }
  122235. }
  122236. declare module BABYLON {
  122237. /**
  122238. * Class containing static functions to help procedurally build meshes
  122239. */
  122240. export class TubeBuilder {
  122241. /**
  122242. * Creates a tube mesh.
  122243. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  122244. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  122245. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  122246. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  122247. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  122248. * * 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)
  122249. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  122250. * * 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
  122251. * * 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
  122252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122253. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122254. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122256. * @param name defines the name of the mesh
  122257. * @param options defines the options used to create the mesh
  122258. * @param scene defines the hosting scene
  122259. * @returns the tube mesh
  122260. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122261. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  122262. */
  122263. static CreateTube(name: string, options: {
  122264. path: Vector3[];
  122265. radius?: number;
  122266. tessellation?: number;
  122267. radiusFunction?: {
  122268. (i: number, distance: number): number;
  122269. };
  122270. cap?: number;
  122271. arc?: number;
  122272. updatable?: boolean;
  122273. sideOrientation?: number;
  122274. frontUVs?: Vector4;
  122275. backUVs?: Vector4;
  122276. instance?: Mesh;
  122277. invertUV?: boolean;
  122278. }, scene?: Nullable<Scene>): Mesh;
  122279. }
  122280. }
  122281. declare module BABYLON {
  122282. /**
  122283. * Class containing static functions to help procedurally build meshes
  122284. */
  122285. export class IcoSphereBuilder {
  122286. /**
  122287. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  122288. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  122289. * * 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`)
  122290. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  122291. * * 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
  122292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122293. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122295. * @param name defines the name of the mesh
  122296. * @param options defines the options used to create the mesh
  122297. * @param scene defines the hosting scene
  122298. * @returns the icosahedron mesh
  122299. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  122300. */
  122301. static CreateIcoSphere(name: string, options: {
  122302. radius?: number;
  122303. radiusX?: number;
  122304. radiusY?: number;
  122305. radiusZ?: number;
  122306. flat?: boolean;
  122307. subdivisions?: number;
  122308. sideOrientation?: number;
  122309. frontUVs?: Vector4;
  122310. backUVs?: Vector4;
  122311. updatable?: boolean;
  122312. }, scene?: Nullable<Scene>): Mesh;
  122313. }
  122314. }
  122315. declare module BABYLON {
  122316. /**
  122317. * Class containing static functions to help procedurally build meshes
  122318. */
  122319. export class DecalBuilder {
  122320. /**
  122321. * Creates a decal mesh.
  122322. * 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
  122323. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  122324. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  122325. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  122326. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  122327. * @param name defines the name of the mesh
  122328. * @param sourceMesh defines the mesh where the decal must be applied
  122329. * @param options defines the options used to create the mesh
  122330. * @param scene defines the hosting scene
  122331. * @returns the decal mesh
  122332. * @see https://doc.babylonjs.com/how_to/decals
  122333. */
  122334. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  122335. position?: Vector3;
  122336. normal?: Vector3;
  122337. size?: Vector3;
  122338. angle?: number;
  122339. }): Mesh;
  122340. }
  122341. }
  122342. declare module BABYLON {
  122343. /**
  122344. * Class containing static functions to help procedurally build meshes
  122345. */
  122346. export class MeshBuilder {
  122347. /**
  122348. * Creates a box mesh
  122349. * * The parameter `size` sets the size (float) of each box side (default 1)
  122350. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  122351. * * 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)
  122352. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122353. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122354. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122356. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  122357. * @param name defines the name of the mesh
  122358. * @param options defines the options used to create the mesh
  122359. * @param scene defines the hosting scene
  122360. * @returns the box mesh
  122361. */
  122362. static CreateBox(name: string, options: {
  122363. size?: number;
  122364. width?: number;
  122365. height?: number;
  122366. depth?: number;
  122367. faceUV?: Vector4[];
  122368. faceColors?: Color4[];
  122369. sideOrientation?: number;
  122370. frontUVs?: Vector4;
  122371. backUVs?: Vector4;
  122372. updatable?: boolean;
  122373. }, scene?: Nullable<Scene>): Mesh;
  122374. /**
  122375. * Creates a tiled box mesh
  122376. * * faceTiles sets the pattern, tile size and number of tiles for a face
  122377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122378. * @param name defines the name of the mesh
  122379. * @param options defines the options used to create the mesh
  122380. * @param scene defines the hosting scene
  122381. * @returns the tiled box mesh
  122382. */
  122383. static CreateTiledBox(name: string, options: {
  122384. pattern?: number;
  122385. size?: number;
  122386. width?: number;
  122387. height?: number;
  122388. depth: number;
  122389. tileSize?: number;
  122390. tileWidth?: number;
  122391. tileHeight?: number;
  122392. faceUV?: Vector4[];
  122393. faceColors?: Color4[];
  122394. alignHorizontal?: number;
  122395. alignVertical?: number;
  122396. sideOrientation?: number;
  122397. updatable?: boolean;
  122398. }, scene?: Nullable<Scene>): Mesh;
  122399. /**
  122400. * Creates a sphere mesh
  122401. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  122402. * * 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`)
  122403. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  122404. * * 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
  122405. * * 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)
  122406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122407. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122409. * @param name defines the name of the mesh
  122410. * @param options defines the options used to create the mesh
  122411. * @param scene defines the hosting scene
  122412. * @returns the sphere mesh
  122413. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  122414. */
  122415. static CreateSphere(name: string, options: {
  122416. segments?: number;
  122417. diameter?: number;
  122418. diameterX?: number;
  122419. diameterY?: number;
  122420. diameterZ?: number;
  122421. arc?: number;
  122422. slice?: number;
  122423. sideOrientation?: number;
  122424. frontUVs?: Vector4;
  122425. backUVs?: Vector4;
  122426. updatable?: boolean;
  122427. }, scene?: Nullable<Scene>): Mesh;
  122428. /**
  122429. * Creates a plane polygonal mesh. By default, this is a disc
  122430. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  122431. * * 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
  122432. * * 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
  122433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122434. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122436. * @param name defines the name of the mesh
  122437. * @param options defines the options used to create the mesh
  122438. * @param scene defines the hosting scene
  122439. * @returns the plane polygonal mesh
  122440. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  122441. */
  122442. static CreateDisc(name: string, options: {
  122443. radius?: number;
  122444. tessellation?: number;
  122445. arc?: number;
  122446. updatable?: boolean;
  122447. sideOrientation?: number;
  122448. frontUVs?: Vector4;
  122449. backUVs?: Vector4;
  122450. }, scene?: Nullable<Scene>): Mesh;
  122451. /**
  122452. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  122453. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  122454. * * 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`)
  122455. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  122456. * * 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
  122457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122460. * @param name defines the name of the mesh
  122461. * @param options defines the options used to create the mesh
  122462. * @param scene defines the hosting scene
  122463. * @returns the icosahedron mesh
  122464. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  122465. */
  122466. static CreateIcoSphere(name: string, options: {
  122467. radius?: number;
  122468. radiusX?: number;
  122469. radiusY?: number;
  122470. radiusZ?: number;
  122471. flat?: boolean;
  122472. subdivisions?: number;
  122473. sideOrientation?: number;
  122474. frontUVs?: Vector4;
  122475. backUVs?: Vector4;
  122476. updatable?: boolean;
  122477. }, scene?: Nullable<Scene>): Mesh;
  122478. /**
  122479. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  122480. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  122481. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  122482. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  122483. * * 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
  122484. * * 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
  122485. * * 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
  122486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122487. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122488. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122489. * * 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
  122490. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  122491. * * 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
  122492. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  122493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122494. * @param name defines the name of the mesh
  122495. * @param options defines the options used to create the mesh
  122496. * @param scene defines the hosting scene
  122497. * @returns the ribbon mesh
  122498. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  122499. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122500. */
  122501. static CreateRibbon(name: string, options: {
  122502. pathArray: Vector3[][];
  122503. closeArray?: boolean;
  122504. closePath?: boolean;
  122505. offset?: number;
  122506. updatable?: boolean;
  122507. sideOrientation?: number;
  122508. frontUVs?: Vector4;
  122509. backUVs?: Vector4;
  122510. instance?: Mesh;
  122511. invertUV?: boolean;
  122512. uvs?: Vector2[];
  122513. colors?: Color4[];
  122514. }, scene?: Nullable<Scene>): Mesh;
  122515. /**
  122516. * Creates a cylinder or a cone mesh
  122517. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  122518. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  122519. * * 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.
  122520. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  122521. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  122522. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  122523. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  122524. * * 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).
  122525. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  122526. * * 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).
  122527. * * 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
  122528. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  122529. * * 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
  122530. * * 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.
  122531. * * If `enclose` is false, a ring surface is one element.
  122532. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  122533. * * 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
  122534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122535. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122537. * @param name defines the name of the mesh
  122538. * @param options defines the options used to create the mesh
  122539. * @param scene defines the hosting scene
  122540. * @returns the cylinder mesh
  122541. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  122542. */
  122543. static CreateCylinder(name: string, options: {
  122544. height?: number;
  122545. diameterTop?: number;
  122546. diameterBottom?: number;
  122547. diameter?: number;
  122548. tessellation?: number;
  122549. subdivisions?: number;
  122550. arc?: number;
  122551. faceColors?: Color4[];
  122552. faceUV?: Vector4[];
  122553. updatable?: boolean;
  122554. hasRings?: boolean;
  122555. enclose?: boolean;
  122556. cap?: number;
  122557. sideOrientation?: number;
  122558. frontUVs?: Vector4;
  122559. backUVs?: Vector4;
  122560. }, scene?: Nullable<Scene>): Mesh;
  122561. /**
  122562. * Creates a torus mesh
  122563. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  122564. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  122565. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  122566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122567. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122569. * @param name defines the name of the mesh
  122570. * @param options defines the options used to create the mesh
  122571. * @param scene defines the hosting scene
  122572. * @returns the torus mesh
  122573. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  122574. */
  122575. static CreateTorus(name: string, options: {
  122576. diameter?: number;
  122577. thickness?: number;
  122578. tessellation?: number;
  122579. updatable?: boolean;
  122580. sideOrientation?: number;
  122581. frontUVs?: Vector4;
  122582. backUVs?: Vector4;
  122583. }, scene?: Nullable<Scene>): Mesh;
  122584. /**
  122585. * Creates a torus knot mesh
  122586. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  122587. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  122588. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  122589. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  122590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122591. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122593. * @param name defines the name of the mesh
  122594. * @param options defines the options used to create the mesh
  122595. * @param scene defines the hosting scene
  122596. * @returns the torus knot mesh
  122597. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  122598. */
  122599. static CreateTorusKnot(name: string, options: {
  122600. radius?: number;
  122601. tube?: number;
  122602. radialSegments?: number;
  122603. tubularSegments?: number;
  122604. p?: number;
  122605. q?: number;
  122606. updatable?: boolean;
  122607. sideOrientation?: number;
  122608. frontUVs?: Vector4;
  122609. backUVs?: Vector4;
  122610. }, scene?: Nullable<Scene>): Mesh;
  122611. /**
  122612. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  122613. * * 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
  122614. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  122615. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  122616. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  122617. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  122618. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  122619. * * 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
  122620. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  122621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122622. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  122623. * @param name defines the name of the new line system
  122624. * @param options defines the options used to create the line system
  122625. * @param scene defines the hosting scene
  122626. * @returns a new line system mesh
  122627. */
  122628. static CreateLineSystem(name: string, options: {
  122629. lines: Vector3[][];
  122630. updatable?: boolean;
  122631. instance?: Nullable<LinesMesh>;
  122632. colors?: Nullable<Color4[][]>;
  122633. useVertexAlpha?: boolean;
  122634. }, scene: Nullable<Scene>): LinesMesh;
  122635. /**
  122636. * Creates a line mesh
  122637. * 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
  122638. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  122639. * * The parameter `points` is an array successive Vector3
  122640. * * 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
  122641. * * The optional parameter `colors` is an array of successive Color4, one per line point
  122642. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  122643. * * When updating an instance, remember that only point positions can change, not the number of points
  122644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122645. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  122646. * @param name defines the name of the new line system
  122647. * @param options defines the options used to create the line system
  122648. * @param scene defines the hosting scene
  122649. * @returns a new line mesh
  122650. */
  122651. static CreateLines(name: string, options: {
  122652. points: Vector3[];
  122653. updatable?: boolean;
  122654. instance?: Nullable<LinesMesh>;
  122655. colors?: Color4[];
  122656. useVertexAlpha?: boolean;
  122657. }, scene?: Nullable<Scene>): LinesMesh;
  122658. /**
  122659. * Creates a dashed line mesh
  122660. * * 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
  122661. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  122662. * * The parameter `points` is an array successive Vector3
  122663. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  122664. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  122665. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  122666. * * 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
  122667. * * When updating an instance, remember that only point positions can change, not the number of points
  122668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122669. * @param name defines the name of the mesh
  122670. * @param options defines the options used to create the mesh
  122671. * @param scene defines the hosting scene
  122672. * @returns the dashed line mesh
  122673. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  122674. */
  122675. static CreateDashedLines(name: string, options: {
  122676. points: Vector3[];
  122677. dashSize?: number;
  122678. gapSize?: number;
  122679. dashNb?: number;
  122680. updatable?: boolean;
  122681. instance?: LinesMesh;
  122682. }, scene?: Nullable<Scene>): LinesMesh;
  122683. /**
  122684. * 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.
  122685. * * 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.
  122686. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  122687. * * 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.
  122688. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  122689. * * 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
  122690. * * 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
  122691. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  122692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122693. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122694. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  122695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122696. * @param name defines the name of the mesh
  122697. * @param options defines the options used to create the mesh
  122698. * @param scene defines the hosting scene
  122699. * @returns the extruded shape mesh
  122700. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122701. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  122702. */
  122703. static ExtrudeShape(name: string, options: {
  122704. shape: Vector3[];
  122705. path: Vector3[];
  122706. scale?: number;
  122707. rotation?: number;
  122708. cap?: number;
  122709. updatable?: boolean;
  122710. sideOrientation?: number;
  122711. frontUVs?: Vector4;
  122712. backUVs?: Vector4;
  122713. instance?: Mesh;
  122714. invertUV?: boolean;
  122715. }, scene?: Nullable<Scene>): Mesh;
  122716. /**
  122717. * Creates an custom extruded shape mesh.
  122718. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  122719. * * 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.
  122720. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  122721. * * 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
  122722. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  122723. * * 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
  122724. * * It must returns a float value that will be the scale value applied to the shape on each path point
  122725. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  122726. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  122727. * * 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
  122728. * * 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
  122729. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  122730. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122731. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122732. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122734. * @param name defines the name of the mesh
  122735. * @param options defines the options used to create the mesh
  122736. * @param scene defines the hosting scene
  122737. * @returns the custom extruded shape mesh
  122738. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  122739. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122740. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  122741. */
  122742. static ExtrudeShapeCustom(name: string, options: {
  122743. shape: Vector3[];
  122744. path: Vector3[];
  122745. scaleFunction?: any;
  122746. rotationFunction?: any;
  122747. ribbonCloseArray?: boolean;
  122748. ribbonClosePath?: boolean;
  122749. cap?: number;
  122750. updatable?: boolean;
  122751. sideOrientation?: number;
  122752. frontUVs?: Vector4;
  122753. backUVs?: Vector4;
  122754. instance?: Mesh;
  122755. invertUV?: boolean;
  122756. }, scene?: Nullable<Scene>): Mesh;
  122757. /**
  122758. * Creates lathe mesh.
  122759. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  122760. * * 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
  122761. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  122762. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  122763. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  122764. * * 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
  122765. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  122766. * * 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
  122767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122768. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122769. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122771. * @param name defines the name of the mesh
  122772. * @param options defines the options used to create the mesh
  122773. * @param scene defines the hosting scene
  122774. * @returns the lathe mesh
  122775. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  122776. */
  122777. static CreateLathe(name: string, options: {
  122778. shape: Vector3[];
  122779. radius?: number;
  122780. tessellation?: number;
  122781. clip?: number;
  122782. arc?: number;
  122783. closed?: boolean;
  122784. updatable?: boolean;
  122785. sideOrientation?: number;
  122786. frontUVs?: Vector4;
  122787. backUVs?: Vector4;
  122788. cap?: number;
  122789. invertUV?: boolean;
  122790. }, scene?: Nullable<Scene>): Mesh;
  122791. /**
  122792. * Creates a tiled plane mesh
  122793. * * You can set a limited pattern arrangement with the tiles
  122794. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122795. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122797. * @param name defines the name of the mesh
  122798. * @param options defines the options used to create the mesh
  122799. * @param scene defines the hosting scene
  122800. * @returns the plane mesh
  122801. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  122802. */
  122803. static CreateTiledPlane(name: string, options: {
  122804. pattern?: number;
  122805. tileSize?: number;
  122806. tileWidth?: number;
  122807. tileHeight?: number;
  122808. size?: number;
  122809. width?: number;
  122810. height?: number;
  122811. alignHorizontal?: number;
  122812. alignVertical?: number;
  122813. sideOrientation?: number;
  122814. frontUVs?: Vector4;
  122815. backUVs?: Vector4;
  122816. updatable?: boolean;
  122817. }, scene?: Nullable<Scene>): Mesh;
  122818. /**
  122819. * Creates a plane mesh
  122820. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  122821. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  122822. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  122823. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122824. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122826. * @param name defines the name of the mesh
  122827. * @param options defines the options used to create the mesh
  122828. * @param scene defines the hosting scene
  122829. * @returns the plane mesh
  122830. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  122831. */
  122832. static CreatePlane(name: string, options: {
  122833. size?: number;
  122834. width?: number;
  122835. height?: number;
  122836. sideOrientation?: number;
  122837. frontUVs?: Vector4;
  122838. backUVs?: Vector4;
  122839. updatable?: boolean;
  122840. sourcePlane?: Plane;
  122841. }, scene?: Nullable<Scene>): Mesh;
  122842. /**
  122843. * Creates a ground mesh
  122844. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  122845. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  122846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122847. * @param name defines the name of the mesh
  122848. * @param options defines the options used to create the mesh
  122849. * @param scene defines the hosting scene
  122850. * @returns the ground mesh
  122851. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  122852. */
  122853. static CreateGround(name: string, options: {
  122854. width?: number;
  122855. height?: number;
  122856. subdivisions?: number;
  122857. subdivisionsX?: number;
  122858. subdivisionsY?: number;
  122859. updatable?: boolean;
  122860. }, scene?: Nullable<Scene>): Mesh;
  122861. /**
  122862. * Creates a tiled ground mesh
  122863. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  122864. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  122865. * * 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
  122866. * * 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
  122867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122868. * @param name defines the name of the mesh
  122869. * @param options defines the options used to create the mesh
  122870. * @param scene defines the hosting scene
  122871. * @returns the tiled ground mesh
  122872. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  122873. */
  122874. static CreateTiledGround(name: string, options: {
  122875. xmin: number;
  122876. zmin: number;
  122877. xmax: number;
  122878. zmax: number;
  122879. subdivisions?: {
  122880. w: number;
  122881. h: number;
  122882. };
  122883. precision?: {
  122884. w: number;
  122885. h: number;
  122886. };
  122887. updatable?: boolean;
  122888. }, scene?: Nullable<Scene>): Mesh;
  122889. /**
  122890. * Creates a ground mesh from a height map
  122891. * * The parameter `url` sets the URL of the height map image resource.
  122892. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  122893. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  122894. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  122895. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  122896. * * 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.
  122897. * * 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).
  122898. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  122899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122900. * @param name defines the name of the mesh
  122901. * @param url defines the url to the height map
  122902. * @param options defines the options used to create the mesh
  122903. * @param scene defines the hosting scene
  122904. * @returns the ground mesh
  122905. * @see https://doc.babylonjs.com/babylon101/height_map
  122906. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  122907. */
  122908. static CreateGroundFromHeightMap(name: string, url: string, options: {
  122909. width?: number;
  122910. height?: number;
  122911. subdivisions?: number;
  122912. minHeight?: number;
  122913. maxHeight?: number;
  122914. colorFilter?: Color3;
  122915. alphaFilter?: number;
  122916. updatable?: boolean;
  122917. onReady?: (mesh: GroundMesh) => void;
  122918. }, scene?: Nullable<Scene>): GroundMesh;
  122919. /**
  122920. * Creates a polygon mesh
  122921. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  122922. * * 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
  122923. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122925. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  122926. * * Remember you can only change the shape positions, not their number when updating a polygon
  122927. * @param name defines the name of the mesh
  122928. * @param options defines the options used to create the mesh
  122929. * @param scene defines the hosting scene
  122930. * @param earcutInjection can be used to inject your own earcut reference
  122931. * @returns the polygon mesh
  122932. */
  122933. static CreatePolygon(name: string, options: {
  122934. shape: Vector3[];
  122935. holes?: Vector3[][];
  122936. depth?: number;
  122937. faceUV?: Vector4[];
  122938. faceColors?: Color4[];
  122939. updatable?: boolean;
  122940. sideOrientation?: number;
  122941. frontUVs?: Vector4;
  122942. backUVs?: Vector4;
  122943. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122944. /**
  122945. * Creates an extruded polygon mesh, with depth in the Y direction.
  122946. * * 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)
  122947. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122948. * @param name defines the name of the mesh
  122949. * @param options defines the options used to create the mesh
  122950. * @param scene defines the hosting scene
  122951. * @param earcutInjection can be used to inject your own earcut reference
  122952. * @returns the polygon mesh
  122953. */
  122954. static ExtrudePolygon(name: string, options: {
  122955. shape: Vector3[];
  122956. holes?: Vector3[][];
  122957. depth?: number;
  122958. faceUV?: Vector4[];
  122959. faceColors?: Color4[];
  122960. updatable?: boolean;
  122961. sideOrientation?: number;
  122962. frontUVs?: Vector4;
  122963. backUVs?: Vector4;
  122964. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122965. /**
  122966. * Creates a tube mesh.
  122967. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  122968. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  122969. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  122970. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  122971. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  122972. * * 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)
  122973. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  122974. * * 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
  122975. * * 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
  122976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122977. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122978. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122980. * @param name defines the name of the mesh
  122981. * @param options defines the options used to create the mesh
  122982. * @param scene defines the hosting scene
  122983. * @returns the tube mesh
  122984. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122985. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  122986. */
  122987. static CreateTube(name: string, options: {
  122988. path: Vector3[];
  122989. radius?: number;
  122990. tessellation?: number;
  122991. radiusFunction?: {
  122992. (i: number, distance: number): number;
  122993. };
  122994. cap?: number;
  122995. arc?: number;
  122996. updatable?: boolean;
  122997. sideOrientation?: number;
  122998. frontUVs?: Vector4;
  122999. backUVs?: Vector4;
  123000. instance?: Mesh;
  123001. invertUV?: boolean;
  123002. }, scene?: Nullable<Scene>): Mesh;
  123003. /**
  123004. * Creates a polyhedron mesh
  123005. * * 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
  123006. * * The parameter `size` (positive float, default 1) sets the polygon size
  123007. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  123008. * * 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`
  123009. * * 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
  123010. * * 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)`)
  123011. * * 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
  123012. * * 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
  123013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123016. * @param name defines the name of the mesh
  123017. * @param options defines the options used to create the mesh
  123018. * @param scene defines the hosting scene
  123019. * @returns the polyhedron mesh
  123020. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  123021. */
  123022. static CreatePolyhedron(name: string, options: {
  123023. type?: number;
  123024. size?: number;
  123025. sizeX?: number;
  123026. sizeY?: number;
  123027. sizeZ?: number;
  123028. custom?: any;
  123029. faceUV?: Vector4[];
  123030. faceColors?: Color4[];
  123031. flat?: boolean;
  123032. updatable?: boolean;
  123033. sideOrientation?: number;
  123034. frontUVs?: Vector4;
  123035. backUVs?: Vector4;
  123036. }, scene?: Nullable<Scene>): Mesh;
  123037. /**
  123038. * Creates a decal mesh.
  123039. * 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
  123040. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123041. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123042. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123043. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123044. * @param name defines the name of the mesh
  123045. * @param sourceMesh defines the mesh where the decal must be applied
  123046. * @param options defines the options used to create the mesh
  123047. * @param scene defines the hosting scene
  123048. * @returns the decal mesh
  123049. * @see https://doc.babylonjs.com/how_to/decals
  123050. */
  123051. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123052. position?: Vector3;
  123053. normal?: Vector3;
  123054. size?: Vector3;
  123055. angle?: number;
  123056. }): Mesh;
  123057. }
  123058. }
  123059. declare module BABYLON {
  123060. /**
  123061. * A simplifier interface for future simplification implementations
  123062. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123063. */
  123064. export interface ISimplifier {
  123065. /**
  123066. * Simplification of a given mesh according to the given settings.
  123067. * Since this requires computation, it is assumed that the function runs async.
  123068. * @param settings The settings of the simplification, including quality and distance
  123069. * @param successCallback A callback that will be called after the mesh was simplified.
  123070. * @param errorCallback in case of an error, this callback will be called. optional.
  123071. */
  123072. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  123073. }
  123074. /**
  123075. * Expected simplification settings.
  123076. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  123077. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123078. */
  123079. export interface ISimplificationSettings {
  123080. /**
  123081. * Gets or sets the expected quality
  123082. */
  123083. quality: number;
  123084. /**
  123085. * Gets or sets the distance when this optimized version should be used
  123086. */
  123087. distance: number;
  123088. /**
  123089. * Gets an already optimized mesh
  123090. */
  123091. optimizeMesh?: boolean;
  123092. }
  123093. /**
  123094. * Class used to specify simplification options
  123095. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123096. */
  123097. export class SimplificationSettings implements ISimplificationSettings {
  123098. /** expected quality */
  123099. quality: number;
  123100. /** distance when this optimized version should be used */
  123101. distance: number;
  123102. /** already optimized mesh */
  123103. optimizeMesh?: boolean | undefined;
  123104. /**
  123105. * Creates a SimplificationSettings
  123106. * @param quality expected quality
  123107. * @param distance distance when this optimized version should be used
  123108. * @param optimizeMesh already optimized mesh
  123109. */
  123110. constructor(
  123111. /** expected quality */
  123112. quality: number,
  123113. /** distance when this optimized version should be used */
  123114. distance: number,
  123115. /** already optimized mesh */
  123116. optimizeMesh?: boolean | undefined);
  123117. }
  123118. /**
  123119. * Interface used to define a simplification task
  123120. */
  123121. export interface ISimplificationTask {
  123122. /**
  123123. * Array of settings
  123124. */
  123125. settings: Array<ISimplificationSettings>;
  123126. /**
  123127. * Simplification type
  123128. */
  123129. simplificationType: SimplificationType;
  123130. /**
  123131. * Mesh to simplify
  123132. */
  123133. mesh: Mesh;
  123134. /**
  123135. * Callback called on success
  123136. */
  123137. successCallback?: () => void;
  123138. /**
  123139. * Defines if parallel processing can be used
  123140. */
  123141. parallelProcessing: boolean;
  123142. }
  123143. /**
  123144. * Queue used to order the simplification tasks
  123145. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123146. */
  123147. export class SimplificationQueue {
  123148. private _simplificationArray;
  123149. /**
  123150. * Gets a boolean indicating that the process is still running
  123151. */
  123152. running: boolean;
  123153. /**
  123154. * Creates a new queue
  123155. */
  123156. constructor();
  123157. /**
  123158. * Adds a new simplification task
  123159. * @param task defines a task to add
  123160. */
  123161. addTask(task: ISimplificationTask): void;
  123162. /**
  123163. * Execute next task
  123164. */
  123165. executeNext(): void;
  123166. /**
  123167. * Execute a simplification task
  123168. * @param task defines the task to run
  123169. */
  123170. runSimplification(task: ISimplificationTask): void;
  123171. private getSimplifier;
  123172. }
  123173. /**
  123174. * The implemented types of simplification
  123175. * At the moment only Quadratic Error Decimation is implemented
  123176. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123177. */
  123178. export enum SimplificationType {
  123179. /** Quadratic error decimation */
  123180. QUADRATIC = 0
  123181. }
  123182. }
  123183. declare module BABYLON {
  123184. interface Scene {
  123185. /** @hidden (Backing field) */
  123186. _simplificationQueue: SimplificationQueue;
  123187. /**
  123188. * Gets or sets the simplification queue attached to the scene
  123189. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123190. */
  123191. simplificationQueue: SimplificationQueue;
  123192. }
  123193. interface Mesh {
  123194. /**
  123195. * Simplify the mesh according to the given array of settings.
  123196. * Function will return immediately and will simplify async
  123197. * @param settings a collection of simplification settings
  123198. * @param parallelProcessing should all levels calculate parallel or one after the other
  123199. * @param simplificationType the type of simplification to run
  123200. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  123201. * @returns the current mesh
  123202. */
  123203. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  123204. }
  123205. /**
  123206. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  123207. * created in a scene
  123208. */
  123209. export class SimplicationQueueSceneComponent implements ISceneComponent {
  123210. /**
  123211. * The component name helpfull to identify the component in the list of scene components.
  123212. */
  123213. readonly name: string;
  123214. /**
  123215. * The scene the component belongs to.
  123216. */
  123217. scene: Scene;
  123218. /**
  123219. * Creates a new instance of the component for the given scene
  123220. * @param scene Defines the scene to register the component in
  123221. */
  123222. constructor(scene: Scene);
  123223. /**
  123224. * Registers the component in a given scene
  123225. */
  123226. register(): void;
  123227. /**
  123228. * Rebuilds the elements related to this component in case of
  123229. * context lost for instance.
  123230. */
  123231. rebuild(): void;
  123232. /**
  123233. * Disposes the component and the associated ressources
  123234. */
  123235. dispose(): void;
  123236. private _beforeCameraUpdate;
  123237. }
  123238. }
  123239. declare module BABYLON {
  123240. /**
  123241. * Navigation plugin interface to add navigation constrained by a navigation mesh
  123242. */
  123243. export interface INavigationEnginePlugin {
  123244. /**
  123245. * plugin name
  123246. */
  123247. name: string;
  123248. /**
  123249. * Creates a navigation mesh
  123250. * @param meshes array of all the geometry used to compute the navigatio mesh
  123251. * @param parameters bunch of parameters used to filter geometry
  123252. */
  123253. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  123254. /**
  123255. * Create a navigation mesh debug mesh
  123256. * @param scene is where the mesh will be added
  123257. * @returns debug display mesh
  123258. */
  123259. createDebugNavMesh(scene: Scene): Mesh;
  123260. /**
  123261. * Get a navigation mesh constrained position, closest to the parameter position
  123262. * @param position world position
  123263. * @returns the closest point to position constrained by the navigation mesh
  123264. */
  123265. getClosestPoint(position: Vector3): Vector3;
  123266. /**
  123267. * Get a navigation mesh constrained position, within a particular radius
  123268. * @param position world position
  123269. * @param maxRadius the maximum distance to the constrained world position
  123270. * @returns the closest point to position constrained by the navigation mesh
  123271. */
  123272. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  123273. /**
  123274. * Compute the final position from a segment made of destination-position
  123275. * @param position world position
  123276. * @param destination world position
  123277. * @returns the resulting point along the navmesh
  123278. */
  123279. moveAlong(position: Vector3, destination: Vector3): Vector3;
  123280. /**
  123281. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  123282. * @param start world position
  123283. * @param end world position
  123284. * @returns array containing world position composing the path
  123285. */
  123286. computePath(start: Vector3, end: Vector3): Vector3[];
  123287. /**
  123288. * If this plugin is supported
  123289. * @returns true if plugin is supported
  123290. */
  123291. isSupported(): boolean;
  123292. /**
  123293. * Create a new Crowd so you can add agents
  123294. * @param maxAgents the maximum agent count in the crowd
  123295. * @param maxAgentRadius the maximum radius an agent can have
  123296. * @param scene to attach the crowd to
  123297. * @returns the crowd you can add agents to
  123298. */
  123299. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  123300. /**
  123301. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  123302. * The queries will try to find a solution within those bounds
  123303. * default is (1,1,1)
  123304. * @param extent x,y,z value that define the extent around the queries point of reference
  123305. */
  123306. setDefaultQueryExtent(extent: Vector3): void;
  123307. /**
  123308. * Get the Bounding box extent specified by setDefaultQueryExtent
  123309. * @returns the box extent values
  123310. */
  123311. getDefaultQueryExtent(): Vector3;
  123312. /**
  123313. * Release all resources
  123314. */
  123315. dispose(): void;
  123316. }
  123317. /**
  123318. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  123319. */
  123320. export interface ICrowd {
  123321. /**
  123322. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  123323. * You can attach anything to that node. The node position is updated in the scene update tick.
  123324. * @param pos world position that will be constrained by the navigation mesh
  123325. * @param parameters agent parameters
  123326. * @param transform hooked to the agent that will be update by the scene
  123327. * @returns agent index
  123328. */
  123329. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  123330. /**
  123331. * Returns the agent position in world space
  123332. * @param index agent index returned by addAgent
  123333. * @returns world space position
  123334. */
  123335. getAgentPosition(index: number): Vector3;
  123336. /**
  123337. * Gets the agent velocity in world space
  123338. * @param index agent index returned by addAgent
  123339. * @returns world space velocity
  123340. */
  123341. getAgentVelocity(index: number): Vector3;
  123342. /**
  123343. * remove a particular agent previously created
  123344. * @param index agent index returned by addAgent
  123345. */
  123346. removeAgent(index: number): void;
  123347. /**
  123348. * get the list of all agents attached to this crowd
  123349. * @returns list of agent indices
  123350. */
  123351. getAgents(): number[];
  123352. /**
  123353. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  123354. * @param deltaTime in seconds
  123355. */
  123356. update(deltaTime: number): void;
  123357. /**
  123358. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  123359. * @param index agent index returned by addAgent
  123360. * @param destination targeted world position
  123361. */
  123362. agentGoto(index: number, destination: Vector3): void;
  123363. /**
  123364. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  123365. * The queries will try to find a solution within those bounds
  123366. * default is (1,1,1)
  123367. * @param extent x,y,z value that define the extent around the queries point of reference
  123368. */
  123369. setDefaultQueryExtent(extent: Vector3): void;
  123370. /**
  123371. * Get the Bounding box extent specified by setDefaultQueryExtent
  123372. * @returns the box extent values
  123373. */
  123374. getDefaultQueryExtent(): Vector3;
  123375. /**
  123376. * Release all resources
  123377. */
  123378. dispose(): void;
  123379. }
  123380. /**
  123381. * Configures an agent
  123382. */
  123383. export interface IAgentParameters {
  123384. /**
  123385. * Agent radius. [Limit: >= 0]
  123386. */
  123387. radius: number;
  123388. /**
  123389. * Agent height. [Limit: > 0]
  123390. */
  123391. height: number;
  123392. /**
  123393. * Maximum allowed acceleration. [Limit: >= 0]
  123394. */
  123395. maxAcceleration: number;
  123396. /**
  123397. * Maximum allowed speed. [Limit: >= 0]
  123398. */
  123399. maxSpeed: number;
  123400. /**
  123401. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  123402. */
  123403. collisionQueryRange: number;
  123404. /**
  123405. * The path visibility optimization range. [Limit: > 0]
  123406. */
  123407. pathOptimizationRange: number;
  123408. /**
  123409. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  123410. */
  123411. separationWeight: number;
  123412. }
  123413. /**
  123414. * Configures the navigation mesh creation
  123415. */
  123416. export interface INavMeshParameters {
  123417. /**
  123418. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  123419. */
  123420. cs: number;
  123421. /**
  123422. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  123423. */
  123424. ch: number;
  123425. /**
  123426. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  123427. */
  123428. walkableSlopeAngle: number;
  123429. /**
  123430. * Minimum floor to 'ceiling' height that will still allow the floor area to
  123431. * be considered walkable. [Limit: >= 3] [Units: vx]
  123432. */
  123433. walkableHeight: number;
  123434. /**
  123435. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  123436. */
  123437. walkableClimb: number;
  123438. /**
  123439. * The distance to erode/shrink the walkable area of the heightfield away from
  123440. * obstructions. [Limit: >=0] [Units: vx]
  123441. */
  123442. walkableRadius: number;
  123443. /**
  123444. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  123445. */
  123446. maxEdgeLen: number;
  123447. /**
  123448. * The maximum distance a simplfied contour's border edges should deviate
  123449. * the original raw contour. [Limit: >=0] [Units: vx]
  123450. */
  123451. maxSimplificationError: number;
  123452. /**
  123453. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  123454. */
  123455. minRegionArea: number;
  123456. /**
  123457. * Any regions with a span count smaller than this value will, if possible,
  123458. * be merged with larger regions. [Limit: >=0] [Units: vx]
  123459. */
  123460. mergeRegionArea: number;
  123461. /**
  123462. * The maximum number of vertices allowed for polygons generated during the
  123463. * contour to polygon conversion process. [Limit: >= 3]
  123464. */
  123465. maxVertsPerPoly: number;
  123466. /**
  123467. * Sets the sampling distance to use when generating the detail mesh.
  123468. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  123469. */
  123470. detailSampleDist: number;
  123471. /**
  123472. * The maximum distance the detail mesh surface should deviate from heightfield
  123473. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  123474. */
  123475. detailSampleMaxError: number;
  123476. }
  123477. }
  123478. declare module BABYLON {
  123479. /**
  123480. * RecastJS navigation plugin
  123481. */
  123482. export class RecastJSPlugin implements INavigationEnginePlugin {
  123483. /**
  123484. * Reference to the Recast library
  123485. */
  123486. bjsRECAST: any;
  123487. /**
  123488. * plugin name
  123489. */
  123490. name: string;
  123491. /**
  123492. * the first navmesh created. We might extend this to support multiple navmeshes
  123493. */
  123494. navMesh: any;
  123495. /**
  123496. * Initializes the recastJS plugin
  123497. * @param recastInjection can be used to inject your own recast reference
  123498. */
  123499. constructor(recastInjection?: any);
  123500. /**
  123501. * Creates a navigation mesh
  123502. * @param meshes array of all the geometry used to compute the navigatio mesh
  123503. * @param parameters bunch of parameters used to filter geometry
  123504. */
  123505. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  123506. /**
  123507. * Create a navigation mesh debug mesh
  123508. * @param scene is where the mesh will be added
  123509. * @returns debug display mesh
  123510. */
  123511. createDebugNavMesh(scene: Scene): Mesh;
  123512. /**
  123513. * Get a navigation mesh constrained position, closest to the parameter position
  123514. * @param position world position
  123515. * @returns the closest point to position constrained by the navigation mesh
  123516. */
  123517. getClosestPoint(position: Vector3): Vector3;
  123518. /**
  123519. * Get a navigation mesh constrained position, within a particular radius
  123520. * @param position world position
  123521. * @param maxRadius the maximum distance to the constrained world position
  123522. * @returns the closest point to position constrained by the navigation mesh
  123523. */
  123524. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  123525. /**
  123526. * Compute the final position from a segment made of destination-position
  123527. * @param position world position
  123528. * @param destination world position
  123529. * @returns the resulting point along the navmesh
  123530. */
  123531. moveAlong(position: Vector3, destination: Vector3): Vector3;
  123532. /**
  123533. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  123534. * @param start world position
  123535. * @param end world position
  123536. * @returns array containing world position composing the path
  123537. */
  123538. computePath(start: Vector3, end: Vector3): Vector3[];
  123539. /**
  123540. * Create a new Crowd so you can add agents
  123541. * @param maxAgents the maximum agent count in the crowd
  123542. * @param maxAgentRadius the maximum radius an agent can have
  123543. * @param scene to attach the crowd to
  123544. * @returns the crowd you can add agents to
  123545. */
  123546. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  123547. /**
  123548. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  123549. * The queries will try to find a solution within those bounds
  123550. * default is (1,1,1)
  123551. * @param extent x,y,z value that define the extent around the queries point of reference
  123552. */
  123553. setDefaultQueryExtent(extent: Vector3): void;
  123554. /**
  123555. * Get the Bounding box extent specified by setDefaultQueryExtent
  123556. * @returns the box extent values
  123557. */
  123558. getDefaultQueryExtent(): Vector3;
  123559. /**
  123560. * Disposes
  123561. */
  123562. dispose(): void;
  123563. /**
  123564. * If this plugin is supported
  123565. * @returns true if plugin is supported
  123566. */
  123567. isSupported(): boolean;
  123568. }
  123569. /**
  123570. * Recast detour crowd implementation
  123571. */
  123572. export class RecastJSCrowd implements ICrowd {
  123573. /**
  123574. * Recast/detour plugin
  123575. */
  123576. bjsRECASTPlugin: RecastJSPlugin;
  123577. /**
  123578. * Link to the detour crowd
  123579. */
  123580. recastCrowd: any;
  123581. /**
  123582. * One transform per agent
  123583. */
  123584. transforms: TransformNode[];
  123585. /**
  123586. * All agents created
  123587. */
  123588. agents: number[];
  123589. /**
  123590. * Link to the scene is kept to unregister the crowd from the scene
  123591. */
  123592. private _scene;
  123593. /**
  123594. * Observer for crowd updates
  123595. */
  123596. private _onBeforeAnimationsObserver;
  123597. /**
  123598. * Constructor
  123599. * @param plugin recastJS plugin
  123600. * @param maxAgents the maximum agent count in the crowd
  123601. * @param maxAgentRadius the maximum radius an agent can have
  123602. * @param scene to attach the crowd to
  123603. * @returns the crowd you can add agents to
  123604. */
  123605. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  123606. /**
  123607. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  123608. * You can attach anything to that node. The node position is updated in the scene update tick.
  123609. * @param pos world position that will be constrained by the navigation mesh
  123610. * @param parameters agent parameters
  123611. * @param transform hooked to the agent that will be update by the scene
  123612. * @returns agent index
  123613. */
  123614. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  123615. /**
  123616. * Returns the agent position in world space
  123617. * @param index agent index returned by addAgent
  123618. * @returns world space position
  123619. */
  123620. getAgentPosition(index: number): Vector3;
  123621. /**
  123622. * Returns the agent velocity in world space
  123623. * @param index agent index returned by addAgent
  123624. * @returns world space velocity
  123625. */
  123626. getAgentVelocity(index: number): Vector3;
  123627. /**
  123628. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  123629. * @param index agent index returned by addAgent
  123630. * @param destination targeted world position
  123631. */
  123632. agentGoto(index: number, destination: Vector3): void;
  123633. /**
  123634. * remove a particular agent previously created
  123635. * @param index agent index returned by addAgent
  123636. */
  123637. removeAgent(index: number): void;
  123638. /**
  123639. * get the list of all agents attached to this crowd
  123640. * @returns list of agent indices
  123641. */
  123642. getAgents(): number[];
  123643. /**
  123644. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  123645. * @param deltaTime in seconds
  123646. */
  123647. update(deltaTime: number): void;
  123648. /**
  123649. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  123650. * The queries will try to find a solution within those bounds
  123651. * default is (1,1,1)
  123652. * @param extent x,y,z value that define the extent around the queries point of reference
  123653. */
  123654. setDefaultQueryExtent(extent: Vector3): void;
  123655. /**
  123656. * Get the Bounding box extent specified by setDefaultQueryExtent
  123657. * @returns the box extent values
  123658. */
  123659. getDefaultQueryExtent(): Vector3;
  123660. /**
  123661. * Release all resources
  123662. */
  123663. dispose(): void;
  123664. }
  123665. }
  123666. declare module BABYLON {
  123667. /**
  123668. * Class used to enable access to IndexedDB
  123669. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  123670. */
  123671. export class Database implements IOfflineProvider {
  123672. private _callbackManifestChecked;
  123673. private _currentSceneUrl;
  123674. private _db;
  123675. private _enableSceneOffline;
  123676. private _enableTexturesOffline;
  123677. private _manifestVersionFound;
  123678. private _mustUpdateRessources;
  123679. private _hasReachedQuota;
  123680. private _isSupported;
  123681. private _idbFactory;
  123682. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  123683. private static IsUASupportingBlobStorage;
  123684. /**
  123685. * Gets a boolean indicating if Database storate is enabled (off by default)
  123686. */
  123687. static IDBStorageEnabled: boolean;
  123688. /**
  123689. * Gets a boolean indicating if scene must be saved in the database
  123690. */
  123691. readonly enableSceneOffline: boolean;
  123692. /**
  123693. * Gets a boolean indicating if textures must be saved in the database
  123694. */
  123695. readonly enableTexturesOffline: boolean;
  123696. /**
  123697. * Creates a new Database
  123698. * @param urlToScene defines the url to load the scene
  123699. * @param callbackManifestChecked defines the callback to use when manifest is checked
  123700. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  123701. */
  123702. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  123703. private static _ParseURL;
  123704. private static _ReturnFullUrlLocation;
  123705. private _checkManifestFile;
  123706. /**
  123707. * Open the database and make it available
  123708. * @param successCallback defines the callback to call on success
  123709. * @param errorCallback defines the callback to call on error
  123710. */
  123711. open(successCallback: () => void, errorCallback: () => void): void;
  123712. /**
  123713. * Loads an image from the database
  123714. * @param url defines the url to load from
  123715. * @param image defines the target DOM image
  123716. */
  123717. loadImage(url: string, image: HTMLImageElement): void;
  123718. private _loadImageFromDBAsync;
  123719. private _saveImageIntoDBAsync;
  123720. private _checkVersionFromDB;
  123721. private _loadVersionFromDBAsync;
  123722. private _saveVersionIntoDBAsync;
  123723. /**
  123724. * Loads a file from database
  123725. * @param url defines the URL to load from
  123726. * @param sceneLoaded defines a callback to call on success
  123727. * @param progressCallBack defines a callback to call when progress changed
  123728. * @param errorCallback defines a callback to call on error
  123729. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  123730. */
  123731. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  123732. private _loadFileAsync;
  123733. private _saveFileAsync;
  123734. /**
  123735. * Validates if xhr data is correct
  123736. * @param xhr defines the request to validate
  123737. * @param dataType defines the expected data type
  123738. * @returns true if data is correct
  123739. */
  123740. private static _ValidateXHRData;
  123741. }
  123742. }
  123743. declare module BABYLON {
  123744. /** @hidden */
  123745. export var gpuUpdateParticlesPixelShader: {
  123746. name: string;
  123747. shader: string;
  123748. };
  123749. }
  123750. declare module BABYLON {
  123751. /** @hidden */
  123752. export var gpuUpdateParticlesVertexShader: {
  123753. name: string;
  123754. shader: string;
  123755. };
  123756. }
  123757. declare module BABYLON {
  123758. /** @hidden */
  123759. export var clipPlaneFragmentDeclaration2: {
  123760. name: string;
  123761. shader: string;
  123762. };
  123763. }
  123764. declare module BABYLON {
  123765. /** @hidden */
  123766. export var gpuRenderParticlesPixelShader: {
  123767. name: string;
  123768. shader: string;
  123769. };
  123770. }
  123771. declare module BABYLON {
  123772. /** @hidden */
  123773. export var clipPlaneVertexDeclaration2: {
  123774. name: string;
  123775. shader: string;
  123776. };
  123777. }
  123778. declare module BABYLON {
  123779. /** @hidden */
  123780. export var gpuRenderParticlesVertexShader: {
  123781. name: string;
  123782. shader: string;
  123783. };
  123784. }
  123785. declare module BABYLON {
  123786. /**
  123787. * This represents a GPU particle system in Babylon
  123788. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  123789. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  123790. */
  123791. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  123792. /**
  123793. * The layer mask we are rendering the particles through.
  123794. */
  123795. layerMask: number;
  123796. private _capacity;
  123797. private _activeCount;
  123798. private _currentActiveCount;
  123799. private _accumulatedCount;
  123800. private _renderEffect;
  123801. private _updateEffect;
  123802. private _buffer0;
  123803. private _buffer1;
  123804. private _spriteBuffer;
  123805. private _updateVAO;
  123806. private _renderVAO;
  123807. private _targetIndex;
  123808. private _sourceBuffer;
  123809. private _targetBuffer;
  123810. private _engine;
  123811. private _currentRenderId;
  123812. private _started;
  123813. private _stopped;
  123814. private _timeDelta;
  123815. private _randomTexture;
  123816. private _randomTexture2;
  123817. private _attributesStrideSize;
  123818. private _updateEffectOptions;
  123819. private _randomTextureSize;
  123820. private _actualFrame;
  123821. private readonly _rawTextureWidth;
  123822. /**
  123823. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  123824. */
  123825. static readonly IsSupported: boolean;
  123826. /**
  123827. * An event triggered when the system is disposed.
  123828. */
  123829. onDisposeObservable: Observable<GPUParticleSystem>;
  123830. /**
  123831. * Gets the maximum number of particles active at the same time.
  123832. * @returns The max number of active particles.
  123833. */
  123834. getCapacity(): number;
  123835. /**
  123836. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  123837. * to override the particles.
  123838. */
  123839. forceDepthWrite: boolean;
  123840. /**
  123841. * Gets or set the number of active particles
  123842. */
  123843. activeParticleCount: number;
  123844. private _preWarmDone;
  123845. /**
  123846. * Is this system ready to be used/rendered
  123847. * @return true if the system is ready
  123848. */
  123849. isReady(): boolean;
  123850. /**
  123851. * Gets if the system has been started. (Note: this will still be true after stop is called)
  123852. * @returns True if it has been started, otherwise false.
  123853. */
  123854. isStarted(): boolean;
  123855. /**
  123856. * Starts the particle system and begins to emit
  123857. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  123858. */
  123859. start(delay?: number): void;
  123860. /**
  123861. * Stops the particle system.
  123862. */
  123863. stop(): void;
  123864. /**
  123865. * Remove all active particles
  123866. */
  123867. reset(): void;
  123868. /**
  123869. * Returns the string "GPUParticleSystem"
  123870. * @returns a string containing the class name
  123871. */
  123872. getClassName(): string;
  123873. private _colorGradientsTexture;
  123874. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  123875. /**
  123876. * Adds a new color gradient
  123877. * @param gradient defines the gradient to use (between 0 and 1)
  123878. * @param color1 defines the color to affect to the specified gradient
  123879. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  123880. * @returns the current particle system
  123881. */
  123882. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  123883. /**
  123884. * Remove a specific color gradient
  123885. * @param gradient defines the gradient to remove
  123886. * @returns the current particle system
  123887. */
  123888. removeColorGradient(gradient: number): GPUParticleSystem;
  123889. private _angularSpeedGradientsTexture;
  123890. private _sizeGradientsTexture;
  123891. private _velocityGradientsTexture;
  123892. private _limitVelocityGradientsTexture;
  123893. private _dragGradientsTexture;
  123894. private _addFactorGradient;
  123895. /**
  123896. * Adds a new size gradient
  123897. * @param gradient defines the gradient to use (between 0 and 1)
  123898. * @param factor defines the size factor to affect to the specified gradient
  123899. * @returns the current particle system
  123900. */
  123901. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  123902. /**
  123903. * Remove a specific size gradient
  123904. * @param gradient defines the gradient to remove
  123905. * @returns the current particle system
  123906. */
  123907. removeSizeGradient(gradient: number): GPUParticleSystem;
  123908. /**
  123909. * Adds a new angular speed gradient
  123910. * @param gradient defines the gradient to use (between 0 and 1)
  123911. * @param factor defines the angular speed to affect to the specified gradient
  123912. * @returns the current particle system
  123913. */
  123914. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  123915. /**
  123916. * Remove a specific angular speed gradient
  123917. * @param gradient defines the gradient to remove
  123918. * @returns the current particle system
  123919. */
  123920. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  123921. /**
  123922. * Adds a new velocity gradient
  123923. * @param gradient defines the gradient to use (between 0 and 1)
  123924. * @param factor defines the velocity to affect to the specified gradient
  123925. * @returns the current particle system
  123926. */
  123927. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  123928. /**
  123929. * Remove a specific velocity gradient
  123930. * @param gradient defines the gradient to remove
  123931. * @returns the current particle system
  123932. */
  123933. removeVelocityGradient(gradient: number): GPUParticleSystem;
  123934. /**
  123935. * Adds a new limit velocity gradient
  123936. * @param gradient defines the gradient to use (between 0 and 1)
  123937. * @param factor defines the limit velocity value to affect to the specified gradient
  123938. * @returns the current particle system
  123939. */
  123940. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  123941. /**
  123942. * Remove a specific limit velocity gradient
  123943. * @param gradient defines the gradient to remove
  123944. * @returns the current particle system
  123945. */
  123946. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  123947. /**
  123948. * Adds a new drag gradient
  123949. * @param gradient defines the gradient to use (between 0 and 1)
  123950. * @param factor defines the drag value to affect to the specified gradient
  123951. * @returns the current particle system
  123952. */
  123953. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  123954. /**
  123955. * Remove a specific drag gradient
  123956. * @param gradient defines the gradient to remove
  123957. * @returns the current particle system
  123958. */
  123959. removeDragGradient(gradient: number): GPUParticleSystem;
  123960. /**
  123961. * Not supported by GPUParticleSystem
  123962. * @param gradient defines the gradient to use (between 0 and 1)
  123963. * @param factor defines the emit rate value to affect to the specified gradient
  123964. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  123965. * @returns the current particle system
  123966. */
  123967. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  123968. /**
  123969. * Not supported by GPUParticleSystem
  123970. * @param gradient defines the gradient to remove
  123971. * @returns the current particle system
  123972. */
  123973. removeEmitRateGradient(gradient: number): IParticleSystem;
  123974. /**
  123975. * Not supported by GPUParticleSystem
  123976. * @param gradient defines the gradient to use (between 0 and 1)
  123977. * @param factor defines the start size value to affect to the specified gradient
  123978. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  123979. * @returns the current particle system
  123980. */
  123981. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  123982. /**
  123983. * Not supported by GPUParticleSystem
  123984. * @param gradient defines the gradient to remove
  123985. * @returns the current particle system
  123986. */
  123987. removeStartSizeGradient(gradient: number): IParticleSystem;
  123988. /**
  123989. * Not supported by GPUParticleSystem
  123990. * @param gradient defines the gradient to use (between 0 and 1)
  123991. * @param min defines the color remap minimal range
  123992. * @param max defines the color remap maximal range
  123993. * @returns the current particle system
  123994. */
  123995. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  123996. /**
  123997. * Not supported by GPUParticleSystem
  123998. * @param gradient defines the gradient to remove
  123999. * @returns the current particle system
  124000. */
  124001. removeColorRemapGradient(): IParticleSystem;
  124002. /**
  124003. * Not supported by GPUParticleSystem
  124004. * @param gradient defines the gradient to use (between 0 and 1)
  124005. * @param min defines the alpha remap minimal range
  124006. * @param max defines the alpha remap maximal range
  124007. * @returns the current particle system
  124008. */
  124009. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124010. /**
  124011. * Not supported by GPUParticleSystem
  124012. * @param gradient defines the gradient to remove
  124013. * @returns the current particle system
  124014. */
  124015. removeAlphaRemapGradient(): IParticleSystem;
  124016. /**
  124017. * Not supported by GPUParticleSystem
  124018. * @param gradient defines the gradient to use (between 0 and 1)
  124019. * @param color defines the color to affect to the specified gradient
  124020. * @returns the current particle system
  124021. */
  124022. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  124023. /**
  124024. * Not supported by GPUParticleSystem
  124025. * @param gradient defines the gradient to remove
  124026. * @returns the current particle system
  124027. */
  124028. removeRampGradient(): IParticleSystem;
  124029. /**
  124030. * Not supported by GPUParticleSystem
  124031. * @returns the list of ramp gradients
  124032. */
  124033. getRampGradients(): Nullable<Array<Color3Gradient>>;
  124034. /**
  124035. * Not supported by GPUParticleSystem
  124036. * Gets or sets a boolean indicating that ramp gradients must be used
  124037. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  124038. */
  124039. useRampGradients: boolean;
  124040. /**
  124041. * Not supported by GPUParticleSystem
  124042. * @param gradient defines the gradient to use (between 0 and 1)
  124043. * @param factor defines the life time factor to affect to the specified gradient
  124044. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124045. * @returns the current particle system
  124046. */
  124047. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124048. /**
  124049. * Not supported by GPUParticleSystem
  124050. * @param gradient defines the gradient to remove
  124051. * @returns the current particle system
  124052. */
  124053. removeLifeTimeGradient(gradient: number): IParticleSystem;
  124054. /**
  124055. * Instantiates a GPU particle system.
  124056. * 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.
  124057. * @param name The name of the particle system
  124058. * @param options The options used to create the system
  124059. * @param scene The scene the particle system belongs to
  124060. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  124061. */
  124062. constructor(name: string, options: Partial<{
  124063. capacity: number;
  124064. randomTextureSize: number;
  124065. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  124066. protected _reset(): void;
  124067. private _createUpdateVAO;
  124068. private _createRenderVAO;
  124069. private _initialize;
  124070. /** @hidden */
  124071. _recreateUpdateEffect(): void;
  124072. /** @hidden */
  124073. _recreateRenderEffect(): void;
  124074. /**
  124075. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  124076. * @param preWarm defines if we are in the pre-warmimg phase
  124077. */
  124078. animate(preWarm?: boolean): void;
  124079. private _createFactorGradientTexture;
  124080. private _createSizeGradientTexture;
  124081. private _createAngularSpeedGradientTexture;
  124082. private _createVelocityGradientTexture;
  124083. private _createLimitVelocityGradientTexture;
  124084. private _createDragGradientTexture;
  124085. private _createColorGradientTexture;
  124086. /**
  124087. * Renders the particle system in its current state
  124088. * @param preWarm defines if the system should only update the particles but not render them
  124089. * @returns the current number of particles
  124090. */
  124091. render(preWarm?: boolean): number;
  124092. /**
  124093. * Rebuilds the particle system
  124094. */
  124095. rebuild(): void;
  124096. private _releaseBuffers;
  124097. private _releaseVAOs;
  124098. /**
  124099. * Disposes the particle system and free the associated resources
  124100. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  124101. */
  124102. dispose(disposeTexture?: boolean): void;
  124103. /**
  124104. * Clones the particle system.
  124105. * @param name The name of the cloned object
  124106. * @param newEmitter The new emitter to use
  124107. * @returns the cloned particle system
  124108. */
  124109. clone(name: string, newEmitter: any): GPUParticleSystem;
  124110. /**
  124111. * Serializes the particle system to a JSON object.
  124112. * @returns the JSON object
  124113. */
  124114. serialize(): any;
  124115. /**
  124116. * Parses a JSON object to create a GPU particle system.
  124117. * @param parsedParticleSystem The JSON object to parse
  124118. * @param scene The scene to create the particle system in
  124119. * @param rootUrl The root url to use to load external dependencies like texture
  124120. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  124121. * @returns the parsed GPU particle system
  124122. */
  124123. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  124124. }
  124125. }
  124126. declare module BABYLON {
  124127. /**
  124128. * Represents a set of particle systems working together to create a specific effect
  124129. */
  124130. export class ParticleSystemSet implements IDisposable {
  124131. private _emitterCreationOptions;
  124132. private _emitterNode;
  124133. /**
  124134. * Gets the particle system list
  124135. */
  124136. systems: IParticleSystem[];
  124137. /**
  124138. * Gets the emitter node used with this set
  124139. */
  124140. readonly emitterNode: Nullable<TransformNode>;
  124141. /**
  124142. * Creates a new emitter mesh as a sphere
  124143. * @param options defines the options used to create the sphere
  124144. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  124145. * @param scene defines the hosting scene
  124146. */
  124147. setEmitterAsSphere(options: {
  124148. diameter: number;
  124149. segments: number;
  124150. color: Color3;
  124151. }, renderingGroupId: number, scene: Scene): void;
  124152. /**
  124153. * Starts all particle systems of the set
  124154. * @param emitter defines an optional mesh to use as emitter for the particle systems
  124155. */
  124156. start(emitter?: AbstractMesh): void;
  124157. /**
  124158. * Release all associated resources
  124159. */
  124160. dispose(): void;
  124161. /**
  124162. * Serialize the set into a JSON compatible object
  124163. * @returns a JSON compatible representation of the set
  124164. */
  124165. serialize(): any;
  124166. /**
  124167. * Parse a new ParticleSystemSet from a serialized source
  124168. * @param data defines a JSON compatible representation of the set
  124169. * @param scene defines the hosting scene
  124170. * @param gpu defines if we want GPU particles or CPU particles
  124171. * @returns a new ParticleSystemSet
  124172. */
  124173. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  124174. }
  124175. }
  124176. declare module BABYLON {
  124177. /**
  124178. * This class is made for on one-liner static method to help creating particle system set.
  124179. */
  124180. export class ParticleHelper {
  124181. /**
  124182. * Gets or sets base Assets URL
  124183. */
  124184. static BaseAssetsUrl: string;
  124185. /**
  124186. * Create a default particle system that you can tweak
  124187. * @param emitter defines the emitter to use
  124188. * @param capacity defines the system capacity (default is 500 particles)
  124189. * @param scene defines the hosting scene
  124190. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  124191. * @returns the new Particle system
  124192. */
  124193. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  124194. /**
  124195. * This is the main static method (one-liner) of this helper to create different particle systems
  124196. * @param type This string represents the type to the particle system to create
  124197. * @param scene The scene where the particle system should live
  124198. * @param gpu If the system will use gpu
  124199. * @returns the ParticleSystemSet created
  124200. */
  124201. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  124202. /**
  124203. * Static function used to export a particle system to a ParticleSystemSet variable.
  124204. * Please note that the emitter shape is not exported
  124205. * @param systems defines the particle systems to export
  124206. * @returns the created particle system set
  124207. */
  124208. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  124209. }
  124210. }
  124211. declare module BABYLON {
  124212. interface Engine {
  124213. /**
  124214. * Create an effect to use with particle systems.
  124215. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  124216. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  124217. * @param uniformsNames defines a list of attribute names
  124218. * @param samplers defines an array of string used to represent textures
  124219. * @param defines defines the string containing the defines to use to compile the shaders
  124220. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  124221. * @param onCompiled defines a function to call when the effect creation is successful
  124222. * @param onError defines a function to call when the effect creation has failed
  124223. * @returns the new Effect
  124224. */
  124225. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  124226. }
  124227. interface Mesh {
  124228. /**
  124229. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  124230. * @returns an array of IParticleSystem
  124231. */
  124232. getEmittedParticleSystems(): IParticleSystem[];
  124233. /**
  124234. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  124235. * @returns an array of IParticleSystem
  124236. */
  124237. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  124238. }
  124239. /**
  124240. * @hidden
  124241. */
  124242. export var _IDoNeedToBeInTheBuild: number;
  124243. }
  124244. declare module BABYLON {
  124245. interface Scene {
  124246. /** @hidden (Backing field) */
  124247. _physicsEngine: Nullable<IPhysicsEngine>;
  124248. /**
  124249. * Gets the current physics engine
  124250. * @returns a IPhysicsEngine or null if none attached
  124251. */
  124252. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  124253. /**
  124254. * Enables physics to the current scene
  124255. * @param gravity defines the scene's gravity for the physics engine
  124256. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  124257. * @return a boolean indicating if the physics engine was initialized
  124258. */
  124259. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  124260. /**
  124261. * Disables and disposes the physics engine associated with the scene
  124262. */
  124263. disablePhysicsEngine(): void;
  124264. /**
  124265. * Gets a boolean indicating if there is an active physics engine
  124266. * @returns a boolean indicating if there is an active physics engine
  124267. */
  124268. isPhysicsEnabled(): boolean;
  124269. /**
  124270. * Deletes a physics compound impostor
  124271. * @param compound defines the compound to delete
  124272. */
  124273. deleteCompoundImpostor(compound: any): void;
  124274. /**
  124275. * An event triggered when physic simulation is about to be run
  124276. */
  124277. onBeforePhysicsObservable: Observable<Scene>;
  124278. /**
  124279. * An event triggered when physic simulation has been done
  124280. */
  124281. onAfterPhysicsObservable: Observable<Scene>;
  124282. }
  124283. interface AbstractMesh {
  124284. /** @hidden */
  124285. _physicsImpostor: Nullable<PhysicsImpostor>;
  124286. /**
  124287. * Gets or sets impostor used for physic simulation
  124288. * @see http://doc.babylonjs.com/features/physics_engine
  124289. */
  124290. physicsImpostor: Nullable<PhysicsImpostor>;
  124291. /**
  124292. * Gets the current physics impostor
  124293. * @see http://doc.babylonjs.com/features/physics_engine
  124294. * @returns a physics impostor or null
  124295. */
  124296. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  124297. /** Apply a physic impulse to the mesh
  124298. * @param force defines the force to apply
  124299. * @param contactPoint defines where to apply the force
  124300. * @returns the current mesh
  124301. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  124302. */
  124303. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  124304. /**
  124305. * Creates a physic joint between two meshes
  124306. * @param otherMesh defines the other mesh to use
  124307. * @param pivot1 defines the pivot to use on this mesh
  124308. * @param pivot2 defines the pivot to use on the other mesh
  124309. * @param options defines additional options (can be plugin dependent)
  124310. * @returns the current mesh
  124311. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  124312. */
  124313. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  124314. /** @hidden */
  124315. _disposePhysicsObserver: Nullable<Observer<Node>>;
  124316. }
  124317. /**
  124318. * Defines the physics engine scene component responsible to manage a physics engine
  124319. */
  124320. export class PhysicsEngineSceneComponent implements ISceneComponent {
  124321. /**
  124322. * The component name helpful to identify the component in the list of scene components.
  124323. */
  124324. readonly name: string;
  124325. /**
  124326. * The scene the component belongs to.
  124327. */
  124328. scene: Scene;
  124329. /**
  124330. * Creates a new instance of the component for the given scene
  124331. * @param scene Defines the scene to register the component in
  124332. */
  124333. constructor(scene: Scene);
  124334. /**
  124335. * Registers the component in a given scene
  124336. */
  124337. register(): void;
  124338. /**
  124339. * Rebuilds the elements related to this component in case of
  124340. * context lost for instance.
  124341. */
  124342. rebuild(): void;
  124343. /**
  124344. * Disposes the component and the associated ressources
  124345. */
  124346. dispose(): void;
  124347. }
  124348. }
  124349. declare module BABYLON {
  124350. /**
  124351. * A helper for physics simulations
  124352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124353. */
  124354. export class PhysicsHelper {
  124355. private _scene;
  124356. private _physicsEngine;
  124357. /**
  124358. * Initializes the Physics helper
  124359. * @param scene Babylon.js scene
  124360. */
  124361. constructor(scene: Scene);
  124362. /**
  124363. * Applies a radial explosion impulse
  124364. * @param origin the origin of the explosion
  124365. * @param radiusOrEventOptions the radius or the options of radial explosion
  124366. * @param strength the explosion strength
  124367. * @param falloff possible options: Constant & Linear. Defaults to Constant
  124368. * @returns A physics radial explosion event, or null
  124369. */
  124370. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  124371. /**
  124372. * Applies a radial explosion force
  124373. * @param origin the origin of the explosion
  124374. * @param radiusOrEventOptions the radius or the options of radial explosion
  124375. * @param strength the explosion strength
  124376. * @param falloff possible options: Constant & Linear. Defaults to Constant
  124377. * @returns A physics radial explosion event, or null
  124378. */
  124379. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  124380. /**
  124381. * Creates a gravitational field
  124382. * @param origin the origin of the explosion
  124383. * @param radiusOrEventOptions the radius or the options of radial explosion
  124384. * @param strength the explosion strength
  124385. * @param falloff possible options: Constant & Linear. Defaults to Constant
  124386. * @returns A physics gravitational field event, or null
  124387. */
  124388. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  124389. /**
  124390. * Creates a physics updraft event
  124391. * @param origin the origin of the updraft
  124392. * @param radiusOrEventOptions the radius or the options of the updraft
  124393. * @param strength the strength of the updraft
  124394. * @param height the height of the updraft
  124395. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  124396. * @returns A physics updraft event, or null
  124397. */
  124398. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  124399. /**
  124400. * Creates a physics vortex event
  124401. * @param origin the of the vortex
  124402. * @param radiusOrEventOptions the radius or the options of the vortex
  124403. * @param strength the strength of the vortex
  124404. * @param height the height of the vortex
  124405. * @returns a Physics vortex event, or null
  124406. * A physics vortex event or null
  124407. */
  124408. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  124409. }
  124410. /**
  124411. * Represents a physics radial explosion event
  124412. */
  124413. class PhysicsRadialExplosionEvent {
  124414. private _scene;
  124415. private _options;
  124416. private _sphere;
  124417. private _dataFetched;
  124418. /**
  124419. * Initializes a radial explosioin event
  124420. * @param _scene BabylonJS scene
  124421. * @param _options The options for the vortex event
  124422. */
  124423. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  124424. /**
  124425. * Returns the data related to the radial explosion event (sphere).
  124426. * @returns The radial explosion event data
  124427. */
  124428. getData(): PhysicsRadialExplosionEventData;
  124429. /**
  124430. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  124431. * @param impostor A physics imposter
  124432. * @param origin the origin of the explosion
  124433. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  124434. */
  124435. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  124436. /**
  124437. * Triggers affecterd impostors callbacks
  124438. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  124439. */
  124440. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  124441. /**
  124442. * Disposes the sphere.
  124443. * @param force Specifies if the sphere should be disposed by force
  124444. */
  124445. dispose(force?: boolean): void;
  124446. /*** Helpers ***/
  124447. private _prepareSphere;
  124448. private _intersectsWithSphere;
  124449. }
  124450. /**
  124451. * Represents a gravitational field event
  124452. */
  124453. class PhysicsGravitationalFieldEvent {
  124454. private _physicsHelper;
  124455. private _scene;
  124456. private _origin;
  124457. private _options;
  124458. private _tickCallback;
  124459. private _sphere;
  124460. private _dataFetched;
  124461. /**
  124462. * Initializes the physics gravitational field event
  124463. * @param _physicsHelper A physics helper
  124464. * @param _scene BabylonJS scene
  124465. * @param _origin The origin position of the gravitational field event
  124466. * @param _options The options for the vortex event
  124467. */
  124468. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  124469. /**
  124470. * Returns the data related to the gravitational field event (sphere).
  124471. * @returns A gravitational field event
  124472. */
  124473. getData(): PhysicsGravitationalFieldEventData;
  124474. /**
  124475. * Enables the gravitational field.
  124476. */
  124477. enable(): void;
  124478. /**
  124479. * Disables the gravitational field.
  124480. */
  124481. disable(): void;
  124482. /**
  124483. * Disposes the sphere.
  124484. * @param force The force to dispose from the gravitational field event
  124485. */
  124486. dispose(force?: boolean): void;
  124487. private _tick;
  124488. }
  124489. /**
  124490. * Represents a physics updraft event
  124491. */
  124492. class PhysicsUpdraftEvent {
  124493. private _scene;
  124494. private _origin;
  124495. private _options;
  124496. private _physicsEngine;
  124497. private _originTop;
  124498. private _originDirection;
  124499. private _tickCallback;
  124500. private _cylinder;
  124501. private _cylinderPosition;
  124502. private _dataFetched;
  124503. /**
  124504. * Initializes the physics updraft event
  124505. * @param _scene BabylonJS scene
  124506. * @param _origin The origin position of the updraft
  124507. * @param _options The options for the updraft event
  124508. */
  124509. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  124510. /**
  124511. * Returns the data related to the updraft event (cylinder).
  124512. * @returns A physics updraft event
  124513. */
  124514. getData(): PhysicsUpdraftEventData;
  124515. /**
  124516. * Enables the updraft.
  124517. */
  124518. enable(): void;
  124519. /**
  124520. * Disables the updraft.
  124521. */
  124522. disable(): void;
  124523. /**
  124524. * Disposes the cylinder.
  124525. * @param force Specifies if the updraft should be disposed by force
  124526. */
  124527. dispose(force?: boolean): void;
  124528. private getImpostorHitData;
  124529. private _tick;
  124530. /*** Helpers ***/
  124531. private _prepareCylinder;
  124532. private _intersectsWithCylinder;
  124533. }
  124534. /**
  124535. * Represents a physics vortex event
  124536. */
  124537. class PhysicsVortexEvent {
  124538. private _scene;
  124539. private _origin;
  124540. private _options;
  124541. private _physicsEngine;
  124542. private _originTop;
  124543. private _tickCallback;
  124544. private _cylinder;
  124545. private _cylinderPosition;
  124546. private _dataFetched;
  124547. /**
  124548. * Initializes the physics vortex event
  124549. * @param _scene The BabylonJS scene
  124550. * @param _origin The origin position of the vortex
  124551. * @param _options The options for the vortex event
  124552. */
  124553. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  124554. /**
  124555. * Returns the data related to the vortex event (cylinder).
  124556. * @returns The physics vortex event data
  124557. */
  124558. getData(): PhysicsVortexEventData;
  124559. /**
  124560. * Enables the vortex.
  124561. */
  124562. enable(): void;
  124563. /**
  124564. * Disables the cortex.
  124565. */
  124566. disable(): void;
  124567. /**
  124568. * Disposes the sphere.
  124569. * @param force
  124570. */
  124571. dispose(force?: boolean): void;
  124572. private getImpostorHitData;
  124573. private _tick;
  124574. /*** Helpers ***/
  124575. private _prepareCylinder;
  124576. private _intersectsWithCylinder;
  124577. }
  124578. /**
  124579. * Options fot the radial explosion event
  124580. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124581. */
  124582. export class PhysicsRadialExplosionEventOptions {
  124583. /**
  124584. * The radius of the sphere for the radial explosion.
  124585. */
  124586. radius: number;
  124587. /**
  124588. * The strenth of the explosion.
  124589. */
  124590. strength: number;
  124591. /**
  124592. * The strenght of the force in correspondence to the distance of the affected object
  124593. */
  124594. falloff: PhysicsRadialImpulseFalloff;
  124595. /**
  124596. * Sphere options for the radial explosion.
  124597. */
  124598. sphere: {
  124599. segments: number;
  124600. diameter: number;
  124601. };
  124602. /**
  124603. * Sphere options for the radial explosion.
  124604. */
  124605. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  124606. }
  124607. /**
  124608. * Options fot the updraft event
  124609. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124610. */
  124611. export class PhysicsUpdraftEventOptions {
  124612. /**
  124613. * The radius of the cylinder for the vortex
  124614. */
  124615. radius: number;
  124616. /**
  124617. * The strenth of the updraft.
  124618. */
  124619. strength: number;
  124620. /**
  124621. * The height of the cylinder for the updraft.
  124622. */
  124623. height: number;
  124624. /**
  124625. * The mode for the the updraft.
  124626. */
  124627. updraftMode: PhysicsUpdraftMode;
  124628. }
  124629. /**
  124630. * Options fot the vortex event
  124631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124632. */
  124633. export class PhysicsVortexEventOptions {
  124634. /**
  124635. * The radius of the cylinder for the vortex
  124636. */
  124637. radius: number;
  124638. /**
  124639. * The strenth of the vortex.
  124640. */
  124641. strength: number;
  124642. /**
  124643. * The height of the cylinder for the vortex.
  124644. */
  124645. height: number;
  124646. /**
  124647. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  124648. */
  124649. centripetalForceThreshold: number;
  124650. /**
  124651. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  124652. */
  124653. centripetalForceMultiplier: number;
  124654. /**
  124655. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  124656. */
  124657. centrifugalForceMultiplier: number;
  124658. /**
  124659. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  124660. */
  124661. updraftForceMultiplier: number;
  124662. }
  124663. /**
  124664. * The strenght of the force in correspondence to the distance of the affected object
  124665. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124666. */
  124667. export enum PhysicsRadialImpulseFalloff {
  124668. /** Defines that impulse is constant in strength across it's whole radius */
  124669. Constant = 0,
  124670. /** Defines that impulse gets weaker if it's further from the origin */
  124671. Linear = 1
  124672. }
  124673. /**
  124674. * The strength of the force in correspondence to the distance of the affected object
  124675. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124676. */
  124677. export enum PhysicsUpdraftMode {
  124678. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  124679. Center = 0,
  124680. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  124681. Perpendicular = 1
  124682. }
  124683. /**
  124684. * Interface for a physics hit data
  124685. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124686. */
  124687. export interface PhysicsHitData {
  124688. /**
  124689. * The force applied at the contact point
  124690. */
  124691. force: Vector3;
  124692. /**
  124693. * The contact point
  124694. */
  124695. contactPoint: Vector3;
  124696. /**
  124697. * The distance from the origin to the contact point
  124698. */
  124699. distanceFromOrigin: number;
  124700. }
  124701. /**
  124702. * Interface for radial explosion event data
  124703. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124704. */
  124705. export interface PhysicsRadialExplosionEventData {
  124706. /**
  124707. * A sphere used for the radial explosion event
  124708. */
  124709. sphere: Mesh;
  124710. }
  124711. /**
  124712. * Interface for gravitational field event data
  124713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124714. */
  124715. export interface PhysicsGravitationalFieldEventData {
  124716. /**
  124717. * A sphere mesh used for the gravitational field event
  124718. */
  124719. sphere: Mesh;
  124720. }
  124721. /**
  124722. * Interface for updraft event data
  124723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124724. */
  124725. export interface PhysicsUpdraftEventData {
  124726. /**
  124727. * A cylinder used for the updraft event
  124728. */
  124729. cylinder: Mesh;
  124730. }
  124731. /**
  124732. * Interface for vortex event data
  124733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124734. */
  124735. export interface PhysicsVortexEventData {
  124736. /**
  124737. * A cylinder used for the vortex event
  124738. */
  124739. cylinder: Mesh;
  124740. }
  124741. /**
  124742. * Interface for an affected physics impostor
  124743. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124744. */
  124745. export interface PhysicsAffectedImpostorWithData {
  124746. /**
  124747. * The impostor affected by the effect
  124748. */
  124749. impostor: PhysicsImpostor;
  124750. /**
  124751. * The data about the hit/horce from the explosion
  124752. */
  124753. hitData: PhysicsHitData;
  124754. }
  124755. }
  124756. declare module BABYLON {
  124757. /** @hidden */
  124758. export var blackAndWhitePixelShader: {
  124759. name: string;
  124760. shader: string;
  124761. };
  124762. }
  124763. declare module BABYLON {
  124764. /**
  124765. * Post process used to render in black and white
  124766. */
  124767. export class BlackAndWhitePostProcess extends PostProcess {
  124768. /**
  124769. * Linear about to convert he result to black and white (default: 1)
  124770. */
  124771. degree: number;
  124772. /**
  124773. * Creates a black and white post process
  124774. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  124775. * @param name The name of the effect.
  124776. * @param options The required width/height ratio to downsize to before computing the render pass.
  124777. * @param camera The camera to apply the render pass to.
  124778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124779. * @param engine The engine which the post process will be applied. (default: current engine)
  124780. * @param reusable If the post process can be reused on the same frame. (default: false)
  124781. */
  124782. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124783. }
  124784. }
  124785. declare module BABYLON {
  124786. /**
  124787. * This represents a set of one or more post processes in Babylon.
  124788. * A post process can be used to apply a shader to a texture after it is rendered.
  124789. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124790. */
  124791. export class PostProcessRenderEffect {
  124792. private _postProcesses;
  124793. private _getPostProcesses;
  124794. private _singleInstance;
  124795. private _cameras;
  124796. private _indicesForCamera;
  124797. /**
  124798. * Name of the effect
  124799. * @hidden
  124800. */
  124801. _name: string;
  124802. /**
  124803. * Instantiates a post process render effect.
  124804. * A post process can be used to apply a shader to a texture after it is rendered.
  124805. * @param engine The engine the effect is tied to
  124806. * @param name The name of the effect
  124807. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  124808. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  124809. */
  124810. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  124811. /**
  124812. * Checks if all the post processes in the effect are supported.
  124813. */
  124814. readonly isSupported: boolean;
  124815. /**
  124816. * Updates the current state of the effect
  124817. * @hidden
  124818. */
  124819. _update(): void;
  124820. /**
  124821. * Attaches the effect on cameras
  124822. * @param cameras The camera to attach to.
  124823. * @hidden
  124824. */
  124825. _attachCameras(cameras: Camera): void;
  124826. /**
  124827. * Attaches the effect on cameras
  124828. * @param cameras The camera to attach to.
  124829. * @hidden
  124830. */
  124831. _attachCameras(cameras: Camera[]): void;
  124832. /**
  124833. * Detaches the effect on cameras
  124834. * @param cameras The camera to detatch from.
  124835. * @hidden
  124836. */
  124837. _detachCameras(cameras: Camera): void;
  124838. /**
  124839. * Detatches the effect on cameras
  124840. * @param cameras The camera to detatch from.
  124841. * @hidden
  124842. */
  124843. _detachCameras(cameras: Camera[]): void;
  124844. /**
  124845. * Enables the effect on given cameras
  124846. * @param cameras The camera to enable.
  124847. * @hidden
  124848. */
  124849. _enable(cameras: Camera): void;
  124850. /**
  124851. * Enables the effect on given cameras
  124852. * @param cameras The camera to enable.
  124853. * @hidden
  124854. */
  124855. _enable(cameras: Nullable<Camera[]>): void;
  124856. /**
  124857. * Disables the effect on the given cameras
  124858. * @param cameras The camera to disable.
  124859. * @hidden
  124860. */
  124861. _disable(cameras: Camera): void;
  124862. /**
  124863. * Disables the effect on the given cameras
  124864. * @param cameras The camera to disable.
  124865. * @hidden
  124866. */
  124867. _disable(cameras: Nullable<Camera[]>): void;
  124868. /**
  124869. * Gets a list of the post processes contained in the effect.
  124870. * @param camera The camera to get the post processes on.
  124871. * @returns The list of the post processes in the effect.
  124872. */
  124873. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  124874. }
  124875. }
  124876. declare module BABYLON {
  124877. /** @hidden */
  124878. export var extractHighlightsPixelShader: {
  124879. name: string;
  124880. shader: string;
  124881. };
  124882. }
  124883. declare module BABYLON {
  124884. /**
  124885. * 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.
  124886. */
  124887. export class ExtractHighlightsPostProcess extends PostProcess {
  124888. /**
  124889. * The luminance threshold, pixels below this value will be set to black.
  124890. */
  124891. threshold: number;
  124892. /** @hidden */
  124893. _exposure: number;
  124894. /**
  124895. * Post process which has the input texture to be used when performing highlight extraction
  124896. * @hidden
  124897. */
  124898. _inputPostProcess: Nullable<PostProcess>;
  124899. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124900. }
  124901. }
  124902. declare module BABYLON {
  124903. /** @hidden */
  124904. export var bloomMergePixelShader: {
  124905. name: string;
  124906. shader: string;
  124907. };
  124908. }
  124909. declare module BABYLON {
  124910. /**
  124911. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  124912. */
  124913. export class BloomMergePostProcess extends PostProcess {
  124914. /** Weight of the bloom to be added to the original input. */
  124915. weight: number;
  124916. /**
  124917. * Creates a new instance of @see BloomMergePostProcess
  124918. * @param name The name of the effect.
  124919. * @param originalFromInput Post process which's input will be used for the merge.
  124920. * @param blurred Blurred highlights post process which's output will be used.
  124921. * @param weight Weight of the bloom to be added to the original input.
  124922. * @param options The required width/height ratio to downsize to before computing the render pass.
  124923. * @param camera The camera to apply the render pass to.
  124924. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124925. * @param engine The engine which the post process will be applied. (default: current engine)
  124926. * @param reusable If the post process can be reused on the same frame. (default: false)
  124927. * @param textureType Type of textures used when performing the post process. (default: 0)
  124928. * @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)
  124929. */
  124930. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  124931. /** Weight of the bloom to be added to the original input. */
  124932. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124933. }
  124934. }
  124935. declare module BABYLON {
  124936. /**
  124937. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  124938. */
  124939. export class BloomEffect extends PostProcessRenderEffect {
  124940. private bloomScale;
  124941. /**
  124942. * @hidden Internal
  124943. */
  124944. _effects: Array<PostProcess>;
  124945. /**
  124946. * @hidden Internal
  124947. */
  124948. _downscale: ExtractHighlightsPostProcess;
  124949. private _blurX;
  124950. private _blurY;
  124951. private _merge;
  124952. /**
  124953. * The luminance threshold to find bright areas of the image to bloom.
  124954. */
  124955. threshold: number;
  124956. /**
  124957. * The strength of the bloom.
  124958. */
  124959. weight: number;
  124960. /**
  124961. * Specifies the size of the bloom blur kernel, relative to the final output size
  124962. */
  124963. kernel: number;
  124964. /**
  124965. * Creates a new instance of @see BloomEffect
  124966. * @param scene The scene the effect belongs to.
  124967. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  124968. * @param bloomKernel The size of the kernel to be used when applying the blur.
  124969. * @param bloomWeight The the strength of bloom.
  124970. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  124971. * @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)
  124972. */
  124973. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  124974. /**
  124975. * Disposes each of the internal effects for a given camera.
  124976. * @param camera The camera to dispose the effect on.
  124977. */
  124978. disposeEffects(camera: Camera): void;
  124979. /**
  124980. * @hidden Internal
  124981. */
  124982. _updateEffects(): void;
  124983. /**
  124984. * Internal
  124985. * @returns if all the contained post processes are ready.
  124986. * @hidden
  124987. */
  124988. _isReady(): boolean;
  124989. }
  124990. }
  124991. declare module BABYLON {
  124992. /** @hidden */
  124993. export var chromaticAberrationPixelShader: {
  124994. name: string;
  124995. shader: string;
  124996. };
  124997. }
  124998. declare module BABYLON {
  124999. /**
  125000. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  125001. */
  125002. export class ChromaticAberrationPostProcess extends PostProcess {
  125003. /**
  125004. * The amount of seperation of rgb channels (default: 30)
  125005. */
  125006. aberrationAmount: number;
  125007. /**
  125008. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  125009. */
  125010. radialIntensity: number;
  125011. /**
  125012. * 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))
  125013. */
  125014. direction: Vector2;
  125015. /**
  125016. * 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))
  125017. */
  125018. centerPosition: Vector2;
  125019. /**
  125020. * Creates a new instance ChromaticAberrationPostProcess
  125021. * @param name The name of the effect.
  125022. * @param screenWidth The width of the screen to apply the effect on.
  125023. * @param screenHeight The height of the screen to apply the effect on.
  125024. * @param options The required width/height ratio to downsize to before computing the render pass.
  125025. * @param camera The camera to apply the render pass to.
  125026. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125027. * @param engine The engine which the post process will be applied. (default: current engine)
  125028. * @param reusable If the post process can be reused on the same frame. (default: false)
  125029. * @param textureType Type of textures used when performing the post process. (default: 0)
  125030. * @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)
  125031. */
  125032. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125033. }
  125034. }
  125035. declare module BABYLON {
  125036. /** @hidden */
  125037. export var circleOfConfusionPixelShader: {
  125038. name: string;
  125039. shader: string;
  125040. };
  125041. }
  125042. declare module BABYLON {
  125043. /**
  125044. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  125045. */
  125046. export class CircleOfConfusionPostProcess extends PostProcess {
  125047. /**
  125048. * 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.
  125049. */
  125050. lensSize: number;
  125051. /**
  125052. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  125053. */
  125054. fStop: number;
  125055. /**
  125056. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  125057. */
  125058. focusDistance: number;
  125059. /**
  125060. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  125061. */
  125062. focalLength: number;
  125063. private _depthTexture;
  125064. /**
  125065. * Creates a new instance CircleOfConfusionPostProcess
  125066. * @param name The name of the effect.
  125067. * @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.
  125068. * @param options The required width/height ratio to downsize to before computing the render pass.
  125069. * @param camera The camera to apply the render pass to.
  125070. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125071. * @param engine The engine which the post process will be applied. (default: current engine)
  125072. * @param reusable If the post process can be reused on the same frame. (default: false)
  125073. * @param textureType Type of textures used when performing the post process. (default: 0)
  125074. * @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)
  125075. */
  125076. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125077. /**
  125078. * 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.
  125079. */
  125080. depthTexture: RenderTargetTexture;
  125081. }
  125082. }
  125083. declare module BABYLON {
  125084. /** @hidden */
  125085. export var colorCorrectionPixelShader: {
  125086. name: string;
  125087. shader: string;
  125088. };
  125089. }
  125090. declare module BABYLON {
  125091. /**
  125092. *
  125093. * This post-process allows the modification of rendered colors by using
  125094. * a 'look-up table' (LUT). This effect is also called Color Grading.
  125095. *
  125096. * The object needs to be provided an url to a texture containing the color
  125097. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  125098. * Use an image editing software to tweak the LUT to match your needs.
  125099. *
  125100. * For an example of a color LUT, see here:
  125101. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  125102. * For explanations on color grading, see here:
  125103. * @see http://udn.epicgames.com/Three/ColorGrading.html
  125104. *
  125105. */
  125106. export class ColorCorrectionPostProcess extends PostProcess {
  125107. private _colorTableTexture;
  125108. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125109. }
  125110. }
  125111. declare module BABYLON {
  125112. /** @hidden */
  125113. export var convolutionPixelShader: {
  125114. name: string;
  125115. shader: string;
  125116. };
  125117. }
  125118. declare module BABYLON {
  125119. /**
  125120. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  125121. * input texture to perform effects such as edge detection or sharpening
  125122. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  125123. */
  125124. export class ConvolutionPostProcess extends PostProcess {
  125125. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125126. kernel: number[];
  125127. /**
  125128. * Creates a new instance ConvolutionPostProcess
  125129. * @param name The name of the effect.
  125130. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  125131. * @param options The required width/height ratio to downsize to before computing the render pass.
  125132. * @param camera The camera to apply the render pass to.
  125133. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125134. * @param engine The engine which the post process will be applied. (default: current engine)
  125135. * @param reusable If the post process can be reused on the same frame. (default: false)
  125136. * @param textureType Type of textures used when performing the post process. (default: 0)
  125137. */
  125138. constructor(name: string,
  125139. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125140. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  125141. /**
  125142. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125143. */
  125144. static EdgeDetect0Kernel: number[];
  125145. /**
  125146. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125147. */
  125148. static EdgeDetect1Kernel: number[];
  125149. /**
  125150. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125151. */
  125152. static EdgeDetect2Kernel: number[];
  125153. /**
  125154. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125155. */
  125156. static SharpenKernel: number[];
  125157. /**
  125158. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125159. */
  125160. static EmbossKernel: number[];
  125161. /**
  125162. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125163. */
  125164. static GaussianKernel: number[];
  125165. }
  125166. }
  125167. declare module BABYLON {
  125168. /**
  125169. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  125170. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  125171. * based on samples that have a large difference in distance than the center pixel.
  125172. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  125173. */
  125174. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  125175. direction: Vector2;
  125176. /**
  125177. * Creates a new instance CircleOfConfusionPostProcess
  125178. * @param name The name of the effect.
  125179. * @param scene The scene the effect belongs to.
  125180. * @param direction The direction the blur should be applied.
  125181. * @param kernel The size of the kernel used to blur.
  125182. * @param options The required width/height ratio to downsize to before computing the render pass.
  125183. * @param camera The camera to apply the render pass to.
  125184. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  125185. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  125186. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125187. * @param engine The engine which the post process will be applied. (default: current engine)
  125188. * @param reusable If the post process can be reused on the same frame. (default: false)
  125189. * @param textureType Type of textures used when performing the post process. (default: 0)
  125190. * @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)
  125191. */
  125192. 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);
  125193. }
  125194. }
  125195. declare module BABYLON {
  125196. /** @hidden */
  125197. export var depthOfFieldMergePixelShader: {
  125198. name: string;
  125199. shader: string;
  125200. };
  125201. }
  125202. declare module BABYLON {
  125203. /**
  125204. * Options to be set when merging outputs from the default pipeline.
  125205. */
  125206. export class DepthOfFieldMergePostProcessOptions {
  125207. /**
  125208. * The original image to merge on top of
  125209. */
  125210. originalFromInput: PostProcess;
  125211. /**
  125212. * Parameters to perform the merge of the depth of field effect
  125213. */
  125214. depthOfField?: {
  125215. circleOfConfusion: PostProcess;
  125216. blurSteps: Array<PostProcess>;
  125217. };
  125218. /**
  125219. * Parameters to perform the merge of bloom effect
  125220. */
  125221. bloom?: {
  125222. blurred: PostProcess;
  125223. weight: number;
  125224. };
  125225. }
  125226. /**
  125227. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  125228. */
  125229. export class DepthOfFieldMergePostProcess extends PostProcess {
  125230. private blurSteps;
  125231. /**
  125232. * Creates a new instance of DepthOfFieldMergePostProcess
  125233. * @param name The name of the effect.
  125234. * @param originalFromInput Post process which's input will be used for the merge.
  125235. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  125236. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  125237. * @param options The required width/height ratio to downsize to before computing the render pass.
  125238. * @param camera The camera to apply the render pass to.
  125239. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125240. * @param engine The engine which the post process will be applied. (default: current engine)
  125241. * @param reusable If the post process can be reused on the same frame. (default: false)
  125242. * @param textureType Type of textures used when performing the post process. (default: 0)
  125243. * @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)
  125244. */
  125245. 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);
  125246. /**
  125247. * Updates the effect with the current post process compile time values and recompiles the shader.
  125248. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  125249. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  125250. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  125251. * @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
  125252. * @param onCompiled Called when the shader has been compiled.
  125253. * @param onError Called if there is an error when compiling a shader.
  125254. */
  125255. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  125256. }
  125257. }
  125258. declare module BABYLON {
  125259. /**
  125260. * Specifies the level of max blur that should be applied when using the depth of field effect
  125261. */
  125262. export enum DepthOfFieldEffectBlurLevel {
  125263. /**
  125264. * Subtle blur
  125265. */
  125266. Low = 0,
  125267. /**
  125268. * Medium blur
  125269. */
  125270. Medium = 1,
  125271. /**
  125272. * Large blur
  125273. */
  125274. High = 2
  125275. }
  125276. /**
  125277. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  125278. */
  125279. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  125280. private _circleOfConfusion;
  125281. /**
  125282. * @hidden Internal, blurs from high to low
  125283. */
  125284. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  125285. private _depthOfFieldBlurY;
  125286. private _dofMerge;
  125287. /**
  125288. * @hidden Internal post processes in depth of field effect
  125289. */
  125290. _effects: Array<PostProcess>;
  125291. /**
  125292. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  125293. */
  125294. focalLength: number;
  125295. /**
  125296. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  125297. */
  125298. fStop: number;
  125299. /**
  125300. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  125301. */
  125302. focusDistance: number;
  125303. /**
  125304. * 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.
  125305. */
  125306. lensSize: number;
  125307. /**
  125308. * Creates a new instance DepthOfFieldEffect
  125309. * @param scene The scene the effect belongs to.
  125310. * @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.
  125311. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  125312. * @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)
  125313. */
  125314. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  125315. /**
  125316. * Get the current class name of the current effet
  125317. * @returns "DepthOfFieldEffect"
  125318. */
  125319. getClassName(): string;
  125320. /**
  125321. * 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.
  125322. */
  125323. depthTexture: RenderTargetTexture;
  125324. /**
  125325. * Disposes each of the internal effects for a given camera.
  125326. * @param camera The camera to dispose the effect on.
  125327. */
  125328. disposeEffects(camera: Camera): void;
  125329. /**
  125330. * @hidden Internal
  125331. */
  125332. _updateEffects(): void;
  125333. /**
  125334. * Internal
  125335. * @returns if all the contained post processes are ready.
  125336. * @hidden
  125337. */
  125338. _isReady(): boolean;
  125339. }
  125340. }
  125341. declare module BABYLON {
  125342. /** @hidden */
  125343. export var displayPassPixelShader: {
  125344. name: string;
  125345. shader: string;
  125346. };
  125347. }
  125348. declare module BABYLON {
  125349. /**
  125350. * DisplayPassPostProcess which produces an output the same as it's input
  125351. */
  125352. export class DisplayPassPostProcess extends PostProcess {
  125353. /**
  125354. * Creates the DisplayPassPostProcess
  125355. * @param name The name of the effect.
  125356. * @param options The required width/height ratio to downsize to before computing the render pass.
  125357. * @param camera The camera to apply the render pass to.
  125358. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125359. * @param engine The engine which the post process will be applied. (default: current engine)
  125360. * @param reusable If the post process can be reused on the same frame. (default: false)
  125361. */
  125362. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125363. }
  125364. }
  125365. declare module BABYLON {
  125366. /** @hidden */
  125367. export var filterPixelShader: {
  125368. name: string;
  125369. shader: string;
  125370. };
  125371. }
  125372. declare module BABYLON {
  125373. /**
  125374. * Applies a kernel filter to the image
  125375. */
  125376. export class FilterPostProcess extends PostProcess {
  125377. /** The matrix to be applied to the image */
  125378. kernelMatrix: Matrix;
  125379. /**
  125380. *
  125381. * @param name The name of the effect.
  125382. * @param kernelMatrix The matrix to be applied to the image
  125383. * @param options The required width/height ratio to downsize to before computing the render pass.
  125384. * @param camera The camera to apply the render pass to.
  125385. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125386. * @param engine The engine which the post process will be applied. (default: current engine)
  125387. * @param reusable If the post process can be reused on the same frame. (default: false)
  125388. */
  125389. constructor(name: string,
  125390. /** The matrix to be applied to the image */
  125391. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125392. }
  125393. }
  125394. declare module BABYLON {
  125395. /** @hidden */
  125396. export var fxaaPixelShader: {
  125397. name: string;
  125398. shader: string;
  125399. };
  125400. }
  125401. declare module BABYLON {
  125402. /** @hidden */
  125403. export var fxaaVertexShader: {
  125404. name: string;
  125405. shader: string;
  125406. };
  125407. }
  125408. declare module BABYLON {
  125409. /**
  125410. * Fxaa post process
  125411. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  125412. */
  125413. export class FxaaPostProcess extends PostProcess {
  125414. /** @hidden */
  125415. texelWidth: number;
  125416. /** @hidden */
  125417. texelHeight: number;
  125418. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  125419. private _getDefines;
  125420. }
  125421. }
  125422. declare module BABYLON {
  125423. /** @hidden */
  125424. export var grainPixelShader: {
  125425. name: string;
  125426. shader: string;
  125427. };
  125428. }
  125429. declare module BABYLON {
  125430. /**
  125431. * The GrainPostProcess adds noise to the image at mid luminance levels
  125432. */
  125433. export class GrainPostProcess extends PostProcess {
  125434. /**
  125435. * The intensity of the grain added (default: 30)
  125436. */
  125437. intensity: number;
  125438. /**
  125439. * If the grain should be randomized on every frame
  125440. */
  125441. animated: boolean;
  125442. /**
  125443. * Creates a new instance of @see GrainPostProcess
  125444. * @param name The name of the effect.
  125445. * @param options The required width/height ratio to downsize to before computing the render pass.
  125446. * @param camera The camera to apply the render pass to.
  125447. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125448. * @param engine The engine which the post process will be applied. (default: current engine)
  125449. * @param reusable If the post process can be reused on the same frame. (default: false)
  125450. * @param textureType Type of textures used when performing the post process. (default: 0)
  125451. * @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)
  125452. */
  125453. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125454. }
  125455. }
  125456. declare module BABYLON {
  125457. /** @hidden */
  125458. export var highlightsPixelShader: {
  125459. name: string;
  125460. shader: string;
  125461. };
  125462. }
  125463. declare module BABYLON {
  125464. /**
  125465. * Extracts highlights from the image
  125466. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  125467. */
  125468. export class HighlightsPostProcess extends PostProcess {
  125469. /**
  125470. * Extracts highlights from the image
  125471. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  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 texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  125479. */
  125480. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  125481. }
  125482. }
  125483. declare module BABYLON {
  125484. /** @hidden */
  125485. export var mrtFragmentDeclaration: {
  125486. name: string;
  125487. shader: string;
  125488. };
  125489. }
  125490. declare module BABYLON {
  125491. /** @hidden */
  125492. export var geometryPixelShader: {
  125493. name: string;
  125494. shader: string;
  125495. };
  125496. }
  125497. declare module BABYLON {
  125498. /** @hidden */
  125499. export var geometryVertexShader: {
  125500. name: string;
  125501. shader: string;
  125502. };
  125503. }
  125504. declare module BABYLON {
  125505. /** @hidden */
  125506. interface ISavedTransformationMatrix {
  125507. world: Matrix;
  125508. viewProjection: Matrix;
  125509. }
  125510. /**
  125511. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  125512. */
  125513. export class GeometryBufferRenderer {
  125514. /**
  125515. * Constant used to retrieve the position texture index in the G-Buffer textures array
  125516. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  125517. */
  125518. static readonly POSITION_TEXTURE_TYPE: number;
  125519. /**
  125520. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  125521. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  125522. */
  125523. static readonly VELOCITY_TEXTURE_TYPE: number;
  125524. /**
  125525. * Dictionary used to store the previous transformation matrices of each rendered mesh
  125526. * in order to compute objects velocities when enableVelocity is set to "true"
  125527. * @hidden
  125528. */
  125529. _previousTransformationMatrices: {
  125530. [index: number]: ISavedTransformationMatrix;
  125531. };
  125532. /**
  125533. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  125534. * in order to compute objects velocities when enableVelocity is set to "true"
  125535. * @hidden
  125536. */
  125537. _previousBonesTransformationMatrices: {
  125538. [index: number]: Float32Array;
  125539. };
  125540. /**
  125541. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  125542. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  125543. */
  125544. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  125545. private _scene;
  125546. private _multiRenderTarget;
  125547. private _ratio;
  125548. private _enablePosition;
  125549. private _enableVelocity;
  125550. private _positionIndex;
  125551. private _velocityIndex;
  125552. protected _effect: Effect;
  125553. protected _cachedDefines: string;
  125554. /**
  125555. * Set the render list (meshes to be rendered) used in the G buffer.
  125556. */
  125557. renderList: Mesh[];
  125558. /**
  125559. * Gets wether or not G buffer are supported by the running hardware.
  125560. * This requires draw buffer supports
  125561. */
  125562. readonly isSupported: boolean;
  125563. /**
  125564. * Returns the index of the given texture type in the G-Buffer textures array
  125565. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  125566. * @returns the index of the given texture type in the G-Buffer textures array
  125567. */
  125568. getTextureIndex(textureType: number): number;
  125569. /**
  125570. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  125571. */
  125572. /**
  125573. * Sets whether or not objects positions are enabled for the G buffer.
  125574. */
  125575. enablePosition: boolean;
  125576. /**
  125577. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  125578. */
  125579. /**
  125580. * Sets wether or not objects velocities are enabled for the G buffer.
  125581. */
  125582. enableVelocity: boolean;
  125583. /**
  125584. * Gets the scene associated with the buffer.
  125585. */
  125586. readonly scene: Scene;
  125587. /**
  125588. * Gets the ratio used by the buffer during its creation.
  125589. * How big is the buffer related to the main canvas.
  125590. */
  125591. readonly ratio: number;
  125592. /** @hidden */
  125593. static _SceneComponentInitialization: (scene: Scene) => void;
  125594. /**
  125595. * Creates a new G Buffer for the scene
  125596. * @param scene The scene the buffer belongs to
  125597. * @param ratio How big is the buffer related to the main canvas.
  125598. */
  125599. constructor(scene: Scene, ratio?: number);
  125600. /**
  125601. * Checks wether everything is ready to render a submesh to the G buffer.
  125602. * @param subMesh the submesh to check readiness for
  125603. * @param useInstances is the mesh drawn using instance or not
  125604. * @returns true if ready otherwise false
  125605. */
  125606. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125607. /**
  125608. * Gets the current underlying G Buffer.
  125609. * @returns the buffer
  125610. */
  125611. getGBuffer(): MultiRenderTarget;
  125612. /**
  125613. * Gets the number of samples used to render the buffer (anti aliasing).
  125614. */
  125615. /**
  125616. * Sets the number of samples used to render the buffer (anti aliasing).
  125617. */
  125618. samples: number;
  125619. /**
  125620. * Disposes the renderer and frees up associated resources.
  125621. */
  125622. dispose(): void;
  125623. protected _createRenderTargets(): void;
  125624. private _copyBonesTransformationMatrices;
  125625. }
  125626. }
  125627. declare module BABYLON {
  125628. interface Scene {
  125629. /** @hidden (Backing field) */
  125630. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  125631. /**
  125632. * Gets or Sets the current geometry buffer associated to the scene.
  125633. */
  125634. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  125635. /**
  125636. * Enables a GeometryBufferRender and associates it with the scene
  125637. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  125638. * @returns the GeometryBufferRenderer
  125639. */
  125640. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  125641. /**
  125642. * Disables the GeometryBufferRender associated with the scene
  125643. */
  125644. disableGeometryBufferRenderer(): void;
  125645. }
  125646. /**
  125647. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  125648. * in several rendering techniques.
  125649. */
  125650. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  125651. /**
  125652. * The component name helpful to identify the component in the list of scene components.
  125653. */
  125654. readonly name: string;
  125655. /**
  125656. * The scene the component belongs to.
  125657. */
  125658. scene: Scene;
  125659. /**
  125660. * Creates a new instance of the component for the given scene
  125661. * @param scene Defines the scene to register the component in
  125662. */
  125663. constructor(scene: Scene);
  125664. /**
  125665. * Registers the component in a given scene
  125666. */
  125667. register(): void;
  125668. /**
  125669. * Rebuilds the elements related to this component in case of
  125670. * context lost for instance.
  125671. */
  125672. rebuild(): void;
  125673. /**
  125674. * Disposes the component and the associated ressources
  125675. */
  125676. dispose(): void;
  125677. private _gatherRenderTargets;
  125678. }
  125679. }
  125680. declare module BABYLON {
  125681. /** @hidden */
  125682. export var motionBlurPixelShader: {
  125683. name: string;
  125684. shader: string;
  125685. };
  125686. }
  125687. declare module BABYLON {
  125688. /**
  125689. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  125690. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  125691. * As an example, all you have to do is to create the post-process:
  125692. * var mb = new BABYLON.MotionBlurPostProcess(
  125693. * 'mb', // The name of the effect.
  125694. * scene, // The scene containing the objects to blur according to their velocity.
  125695. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  125696. * camera // The camera to apply the render pass to.
  125697. * );
  125698. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  125699. */
  125700. export class MotionBlurPostProcess extends PostProcess {
  125701. /**
  125702. * Defines how much the image is blurred by the movement. Default value is equal to 1
  125703. */
  125704. motionStrength: number;
  125705. /**
  125706. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  125707. */
  125708. /**
  125709. * Sets the number of iterations to be used for motion blur quality
  125710. */
  125711. motionBlurSamples: number;
  125712. private _motionBlurSamples;
  125713. private _geometryBufferRenderer;
  125714. /**
  125715. * Creates a new instance MotionBlurPostProcess
  125716. * @param name The name of the effect.
  125717. * @param scene The scene containing the objects to blur according to their velocity.
  125718. * @param options The required width/height ratio to downsize to before computing the render pass.
  125719. * @param camera The camera to apply the render pass to.
  125720. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125721. * @param engine The engine which the post process will be applied. (default: current engine)
  125722. * @param reusable If the post process can be reused on the same frame. (default: false)
  125723. * @param textureType Type of textures used when performing the post process. (default: 0)
  125724. * @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)
  125725. */
  125726. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125727. /**
  125728. * Excludes the given skinned mesh from computing bones velocities.
  125729. * 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.
  125730. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  125731. */
  125732. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  125733. /**
  125734. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  125735. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  125736. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  125737. */
  125738. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  125739. /**
  125740. * Disposes the post process.
  125741. * @param camera The camera to dispose the post process on.
  125742. */
  125743. dispose(camera?: Camera): void;
  125744. }
  125745. }
  125746. declare module BABYLON {
  125747. /** @hidden */
  125748. export var refractionPixelShader: {
  125749. name: string;
  125750. shader: string;
  125751. };
  125752. }
  125753. declare module BABYLON {
  125754. /**
  125755. * Post process which applies a refractin texture
  125756. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  125757. */
  125758. export class RefractionPostProcess extends PostProcess {
  125759. /** the base color of the refraction (used to taint the rendering) */
  125760. color: Color3;
  125761. /** simulated refraction depth */
  125762. depth: number;
  125763. /** the coefficient of the base color (0 to remove base color tainting) */
  125764. colorLevel: number;
  125765. private _refTexture;
  125766. private _ownRefractionTexture;
  125767. /**
  125768. * Gets or sets the refraction texture
  125769. * Please note that you are responsible for disposing the texture if you set it manually
  125770. */
  125771. refractionTexture: Texture;
  125772. /**
  125773. * Initializes the RefractionPostProcess
  125774. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  125775. * @param name The name of the effect.
  125776. * @param refractionTextureUrl Url of the refraction texture to use
  125777. * @param color the base color of the refraction (used to taint the rendering)
  125778. * @param depth simulated refraction depth
  125779. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  125780. * @param camera The camera to apply the render pass to.
  125781. * @param options The required width/height ratio to downsize to before computing the render pass.
  125782. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125783. * @param engine The engine which the post process will be applied. (default: current engine)
  125784. * @param reusable If the post process can be reused on the same frame. (default: false)
  125785. */
  125786. constructor(name: string, refractionTextureUrl: string,
  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, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125793. /**
  125794. * Disposes of the post process
  125795. * @param camera Camera to dispose post process on
  125796. */
  125797. dispose(camera: Camera): void;
  125798. }
  125799. }
  125800. declare module BABYLON {
  125801. /** @hidden */
  125802. export var sharpenPixelShader: {
  125803. name: string;
  125804. shader: string;
  125805. };
  125806. }
  125807. declare module BABYLON {
  125808. /**
  125809. * The SharpenPostProcess applies a sharpen kernel to every pixel
  125810. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  125811. */
  125812. export class SharpenPostProcess extends PostProcess {
  125813. /**
  125814. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  125815. */
  125816. colorAmount: number;
  125817. /**
  125818. * How much sharpness should be applied (default: 0.3)
  125819. */
  125820. edgeAmount: number;
  125821. /**
  125822. * Creates a new instance ConvolutionPostProcess
  125823. * @param name The name of the effect.
  125824. * @param options The required width/height ratio to downsize to before computing the render pass.
  125825. * @param camera The camera to apply the render pass to.
  125826. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125827. * @param engine The engine which the post process will be applied. (default: current engine)
  125828. * @param reusable If the post process can be reused on the same frame. (default: false)
  125829. * @param textureType Type of textures used when performing the post process. (default: 0)
  125830. * @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)
  125831. */
  125832. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125833. }
  125834. }
  125835. declare module BABYLON {
  125836. /**
  125837. * PostProcessRenderPipeline
  125838. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125839. */
  125840. export class PostProcessRenderPipeline {
  125841. private engine;
  125842. private _renderEffects;
  125843. private _renderEffectsForIsolatedPass;
  125844. /**
  125845. * List of inspectable custom properties (used by the Inspector)
  125846. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  125847. */
  125848. inspectableCustomProperties: IInspectable[];
  125849. /**
  125850. * @hidden
  125851. */
  125852. protected _cameras: Camera[];
  125853. /** @hidden */
  125854. _name: string;
  125855. /**
  125856. * Gets pipeline name
  125857. */
  125858. readonly name: string;
  125859. /**
  125860. * Initializes a PostProcessRenderPipeline
  125861. * @param engine engine to add the pipeline to
  125862. * @param name name of the pipeline
  125863. */
  125864. constructor(engine: Engine, name: string);
  125865. /**
  125866. * Gets the class name
  125867. * @returns "PostProcessRenderPipeline"
  125868. */
  125869. getClassName(): string;
  125870. /**
  125871. * If all the render effects in the pipeline are supported
  125872. */
  125873. readonly isSupported: boolean;
  125874. /**
  125875. * Adds an effect to the pipeline
  125876. * @param renderEffect the effect to add
  125877. */
  125878. addEffect(renderEffect: PostProcessRenderEffect): void;
  125879. /** @hidden */
  125880. _rebuild(): void;
  125881. /** @hidden */
  125882. _enableEffect(renderEffectName: string, cameras: Camera): void;
  125883. /** @hidden */
  125884. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  125885. /** @hidden */
  125886. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  125887. /** @hidden */
  125888. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  125889. /** @hidden */
  125890. _attachCameras(cameras: Camera, unique: boolean): void;
  125891. /** @hidden */
  125892. _attachCameras(cameras: Camera[], unique: boolean): void;
  125893. /** @hidden */
  125894. _detachCameras(cameras: Camera): void;
  125895. /** @hidden */
  125896. _detachCameras(cameras: Nullable<Camera[]>): void;
  125897. /** @hidden */
  125898. _update(): void;
  125899. /** @hidden */
  125900. _reset(): void;
  125901. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  125902. /**
  125903. * Disposes of the pipeline
  125904. */
  125905. dispose(): void;
  125906. }
  125907. }
  125908. declare module BABYLON {
  125909. /**
  125910. * PostProcessRenderPipelineManager class
  125911. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125912. */
  125913. export class PostProcessRenderPipelineManager {
  125914. private _renderPipelines;
  125915. /**
  125916. * Initializes a PostProcessRenderPipelineManager
  125917. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125918. */
  125919. constructor();
  125920. /**
  125921. * Gets the list of supported render pipelines
  125922. */
  125923. readonly supportedPipelines: PostProcessRenderPipeline[];
  125924. /**
  125925. * Adds a pipeline to the manager
  125926. * @param renderPipeline The pipeline to add
  125927. */
  125928. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  125929. /**
  125930. * Attaches a camera to the pipeline
  125931. * @param renderPipelineName The name of the pipeline to attach to
  125932. * @param cameras the camera to attach
  125933. * @param unique if the camera can be attached multiple times to the pipeline
  125934. */
  125935. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  125936. /**
  125937. * Detaches a camera from the pipeline
  125938. * @param renderPipelineName The name of the pipeline to detach from
  125939. * @param cameras the camera to detach
  125940. */
  125941. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  125942. /**
  125943. * Enables an effect by name on a pipeline
  125944. * @param renderPipelineName the name of the pipeline to enable the effect in
  125945. * @param renderEffectName the name of the effect to enable
  125946. * @param cameras the cameras that the effect should be enabled on
  125947. */
  125948. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  125949. /**
  125950. * Disables an effect by name on a pipeline
  125951. * @param renderPipelineName the name of the pipeline to disable the effect in
  125952. * @param renderEffectName the name of the effect to disable
  125953. * @param cameras the cameras that the effect should be disabled on
  125954. */
  125955. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  125956. /**
  125957. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  125958. */
  125959. update(): void;
  125960. /** @hidden */
  125961. _rebuild(): void;
  125962. /**
  125963. * Disposes of the manager and pipelines
  125964. */
  125965. dispose(): void;
  125966. }
  125967. }
  125968. declare module BABYLON {
  125969. interface Scene {
  125970. /** @hidden (Backing field) */
  125971. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  125972. /**
  125973. * Gets the postprocess render pipeline manager
  125974. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125975. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  125976. */
  125977. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  125978. }
  125979. /**
  125980. * Defines the Render Pipeline scene component responsible to rendering pipelines
  125981. */
  125982. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  125983. /**
  125984. * The component name helpfull to identify the component in the list of scene components.
  125985. */
  125986. readonly name: string;
  125987. /**
  125988. * The scene the component belongs to.
  125989. */
  125990. scene: Scene;
  125991. /**
  125992. * Creates a new instance of the component for the given scene
  125993. * @param scene Defines the scene to register the component in
  125994. */
  125995. constructor(scene: Scene);
  125996. /**
  125997. * Registers the component in a given scene
  125998. */
  125999. register(): void;
  126000. /**
  126001. * Rebuilds the elements related to this component in case of
  126002. * context lost for instance.
  126003. */
  126004. rebuild(): void;
  126005. /**
  126006. * Disposes the component and the associated ressources
  126007. */
  126008. dispose(): void;
  126009. private _gatherRenderTargets;
  126010. }
  126011. }
  126012. declare module BABYLON {
  126013. /**
  126014. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  126015. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126016. */
  126017. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  126018. private _scene;
  126019. private _camerasToBeAttached;
  126020. /**
  126021. * ID of the sharpen post process,
  126022. */
  126023. private readonly SharpenPostProcessId;
  126024. /**
  126025. * @ignore
  126026. * ID of the image processing post process;
  126027. */
  126028. readonly ImageProcessingPostProcessId: string;
  126029. /**
  126030. * @ignore
  126031. * ID of the Fast Approximate Anti-Aliasing post process;
  126032. */
  126033. readonly FxaaPostProcessId: string;
  126034. /**
  126035. * ID of the chromatic aberration post process,
  126036. */
  126037. private readonly ChromaticAberrationPostProcessId;
  126038. /**
  126039. * ID of the grain post process
  126040. */
  126041. private readonly GrainPostProcessId;
  126042. /**
  126043. * Sharpen post process which will apply a sharpen convolution to enhance edges
  126044. */
  126045. sharpen: SharpenPostProcess;
  126046. private _sharpenEffect;
  126047. private bloom;
  126048. /**
  126049. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  126050. */
  126051. depthOfField: DepthOfFieldEffect;
  126052. /**
  126053. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  126054. */
  126055. fxaa: FxaaPostProcess;
  126056. /**
  126057. * Image post processing pass used to perform operations such as tone mapping or color grading.
  126058. */
  126059. imageProcessing: ImageProcessingPostProcess;
  126060. /**
  126061. * Chromatic aberration post process which will shift rgb colors in the image
  126062. */
  126063. chromaticAberration: ChromaticAberrationPostProcess;
  126064. private _chromaticAberrationEffect;
  126065. /**
  126066. * Grain post process which add noise to the image
  126067. */
  126068. grain: GrainPostProcess;
  126069. private _grainEffect;
  126070. /**
  126071. * Glow post process which adds a glow to emissive areas of the image
  126072. */
  126073. private _glowLayer;
  126074. /**
  126075. * Animations which can be used to tweak settings over a period of time
  126076. */
  126077. animations: Animation[];
  126078. private _imageProcessingConfigurationObserver;
  126079. private _sharpenEnabled;
  126080. private _bloomEnabled;
  126081. private _depthOfFieldEnabled;
  126082. private _depthOfFieldBlurLevel;
  126083. private _fxaaEnabled;
  126084. private _imageProcessingEnabled;
  126085. private _defaultPipelineTextureType;
  126086. private _bloomScale;
  126087. private _chromaticAberrationEnabled;
  126088. private _grainEnabled;
  126089. private _buildAllowed;
  126090. /**
  126091. * Gets active scene
  126092. */
  126093. readonly scene: Scene;
  126094. /**
  126095. * Enable or disable the sharpen process from the pipeline
  126096. */
  126097. sharpenEnabled: boolean;
  126098. private _resizeObserver;
  126099. private _hardwareScaleLevel;
  126100. private _bloomKernel;
  126101. /**
  126102. * Specifies the size of the bloom blur kernel, relative to the final output size
  126103. */
  126104. bloomKernel: number;
  126105. /**
  126106. * Specifies the weight of the bloom in the final rendering
  126107. */
  126108. private _bloomWeight;
  126109. /**
  126110. * Specifies the luma threshold for the area that will be blurred by the bloom
  126111. */
  126112. private _bloomThreshold;
  126113. private _hdr;
  126114. /**
  126115. * The strength of the bloom.
  126116. */
  126117. bloomWeight: number;
  126118. /**
  126119. * The strength of the bloom.
  126120. */
  126121. bloomThreshold: number;
  126122. /**
  126123. * The scale of the bloom, lower value will provide better performance.
  126124. */
  126125. bloomScale: number;
  126126. /**
  126127. * Enable or disable the bloom from the pipeline
  126128. */
  126129. bloomEnabled: boolean;
  126130. private _rebuildBloom;
  126131. /**
  126132. * If the depth of field is enabled.
  126133. */
  126134. depthOfFieldEnabled: boolean;
  126135. /**
  126136. * Blur level of the depth of field effect. (Higher blur will effect performance)
  126137. */
  126138. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  126139. /**
  126140. * If the anti aliasing is enabled.
  126141. */
  126142. fxaaEnabled: boolean;
  126143. private _samples;
  126144. /**
  126145. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  126146. */
  126147. samples: number;
  126148. /**
  126149. * If image processing is enabled.
  126150. */
  126151. imageProcessingEnabled: boolean;
  126152. /**
  126153. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  126154. */
  126155. glowLayerEnabled: boolean;
  126156. /**
  126157. * Gets the glow layer (or null if not defined)
  126158. */
  126159. readonly glowLayer: Nullable<GlowLayer>;
  126160. /**
  126161. * Enable or disable the chromaticAberration process from the pipeline
  126162. */
  126163. chromaticAberrationEnabled: boolean;
  126164. /**
  126165. * Enable or disable the grain process from the pipeline
  126166. */
  126167. grainEnabled: boolean;
  126168. /**
  126169. * @constructor
  126170. * @param name - The rendering pipeline name (default: "")
  126171. * @param hdr - If high dynamic range textures should be used (default: true)
  126172. * @param scene - The scene linked to this pipeline (default: the last created scene)
  126173. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  126174. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  126175. */
  126176. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  126177. /**
  126178. * Get the class name
  126179. * @returns "DefaultRenderingPipeline"
  126180. */
  126181. getClassName(): string;
  126182. /**
  126183. * Force the compilation of the entire pipeline.
  126184. */
  126185. prepare(): void;
  126186. private _hasCleared;
  126187. private _prevPostProcess;
  126188. private _prevPrevPostProcess;
  126189. private _setAutoClearAndTextureSharing;
  126190. private _depthOfFieldSceneObserver;
  126191. private _buildPipeline;
  126192. private _disposePostProcesses;
  126193. /**
  126194. * Adds a camera to the pipeline
  126195. * @param camera the camera to be added
  126196. */
  126197. addCamera(camera: Camera): void;
  126198. /**
  126199. * Removes a camera from the pipeline
  126200. * @param camera the camera to remove
  126201. */
  126202. removeCamera(camera: Camera): void;
  126203. /**
  126204. * Dispose of the pipeline and stop all post processes
  126205. */
  126206. dispose(): void;
  126207. /**
  126208. * Serialize the rendering pipeline (Used when exporting)
  126209. * @returns the serialized object
  126210. */
  126211. serialize(): any;
  126212. /**
  126213. * Parse the serialized pipeline
  126214. * @param source Source pipeline.
  126215. * @param scene The scene to load the pipeline to.
  126216. * @param rootUrl The URL of the serialized pipeline.
  126217. * @returns An instantiated pipeline from the serialized object.
  126218. */
  126219. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  126220. }
  126221. }
  126222. declare module BABYLON {
  126223. /** @hidden */
  126224. export var lensHighlightsPixelShader: {
  126225. name: string;
  126226. shader: string;
  126227. };
  126228. }
  126229. declare module BABYLON {
  126230. /** @hidden */
  126231. export var depthOfFieldPixelShader: {
  126232. name: string;
  126233. shader: string;
  126234. };
  126235. }
  126236. declare module BABYLON {
  126237. /**
  126238. * BABYLON.JS Chromatic Aberration GLSL Shader
  126239. * Author: Olivier Guyot
  126240. * Separates very slightly R, G and B colors on the edges of the screen
  126241. * Inspired by Francois Tarlier & Martins Upitis
  126242. */
  126243. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  126244. /**
  126245. * @ignore
  126246. * The chromatic aberration PostProcess id in the pipeline
  126247. */
  126248. LensChromaticAberrationEffect: string;
  126249. /**
  126250. * @ignore
  126251. * The highlights enhancing PostProcess id in the pipeline
  126252. */
  126253. HighlightsEnhancingEffect: string;
  126254. /**
  126255. * @ignore
  126256. * The depth-of-field PostProcess id in the pipeline
  126257. */
  126258. LensDepthOfFieldEffect: string;
  126259. private _scene;
  126260. private _depthTexture;
  126261. private _grainTexture;
  126262. private _chromaticAberrationPostProcess;
  126263. private _highlightsPostProcess;
  126264. private _depthOfFieldPostProcess;
  126265. private _edgeBlur;
  126266. private _grainAmount;
  126267. private _chromaticAberration;
  126268. private _distortion;
  126269. private _highlightsGain;
  126270. private _highlightsThreshold;
  126271. private _dofDistance;
  126272. private _dofAperture;
  126273. private _dofDarken;
  126274. private _dofPentagon;
  126275. private _blurNoise;
  126276. /**
  126277. * @constructor
  126278. *
  126279. * Effect parameters are as follow:
  126280. * {
  126281. * chromatic_aberration: number; // from 0 to x (1 for realism)
  126282. * edge_blur: number; // from 0 to x (1 for realism)
  126283. * distortion: number; // from 0 to x (1 for realism)
  126284. * grain_amount: number; // from 0 to 1
  126285. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  126286. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  126287. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  126288. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  126289. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  126290. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  126291. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  126292. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  126293. * }
  126294. * Note: if an effect parameter is unset, effect is disabled
  126295. *
  126296. * @param name The rendering pipeline name
  126297. * @param parameters - An object containing all parameters (see above)
  126298. * @param scene The scene linked to this pipeline
  126299. * @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)
  126300. * @param cameras The array of cameras that the rendering pipeline will be attached to
  126301. */
  126302. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  126303. /**
  126304. * Get the class name
  126305. * @returns "LensRenderingPipeline"
  126306. */
  126307. getClassName(): string;
  126308. /**
  126309. * Gets associated scene
  126310. */
  126311. readonly scene: Scene;
  126312. /**
  126313. * Gets or sets the edge blur
  126314. */
  126315. edgeBlur: number;
  126316. /**
  126317. * Gets or sets the grain amount
  126318. */
  126319. grainAmount: number;
  126320. /**
  126321. * Gets or sets the chromatic aberration amount
  126322. */
  126323. chromaticAberration: number;
  126324. /**
  126325. * Gets or sets the depth of field aperture
  126326. */
  126327. dofAperture: number;
  126328. /**
  126329. * Gets or sets the edge distortion
  126330. */
  126331. edgeDistortion: number;
  126332. /**
  126333. * Gets or sets the depth of field distortion
  126334. */
  126335. dofDistortion: number;
  126336. /**
  126337. * Gets or sets the darken out of focus amount
  126338. */
  126339. darkenOutOfFocus: number;
  126340. /**
  126341. * Gets or sets a boolean indicating if blur noise is enabled
  126342. */
  126343. blurNoise: boolean;
  126344. /**
  126345. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  126346. */
  126347. pentagonBokeh: boolean;
  126348. /**
  126349. * Gets or sets the highlight grain amount
  126350. */
  126351. highlightsGain: number;
  126352. /**
  126353. * Gets or sets the highlight threshold
  126354. */
  126355. highlightsThreshold: number;
  126356. /**
  126357. * Sets the amount of blur at the edges
  126358. * @param amount blur amount
  126359. */
  126360. setEdgeBlur(amount: number): void;
  126361. /**
  126362. * Sets edge blur to 0
  126363. */
  126364. disableEdgeBlur(): void;
  126365. /**
  126366. * Sets the amout of grain
  126367. * @param amount Amount of grain
  126368. */
  126369. setGrainAmount(amount: number): void;
  126370. /**
  126371. * Set grain amount to 0
  126372. */
  126373. disableGrain(): void;
  126374. /**
  126375. * Sets the chromatic aberration amount
  126376. * @param amount amount of chromatic aberration
  126377. */
  126378. setChromaticAberration(amount: number): void;
  126379. /**
  126380. * Sets chromatic aberration amount to 0
  126381. */
  126382. disableChromaticAberration(): void;
  126383. /**
  126384. * Sets the EdgeDistortion amount
  126385. * @param amount amount of EdgeDistortion
  126386. */
  126387. setEdgeDistortion(amount: number): void;
  126388. /**
  126389. * Sets edge distortion to 0
  126390. */
  126391. disableEdgeDistortion(): void;
  126392. /**
  126393. * Sets the FocusDistance amount
  126394. * @param amount amount of FocusDistance
  126395. */
  126396. setFocusDistance(amount: number): void;
  126397. /**
  126398. * Disables depth of field
  126399. */
  126400. disableDepthOfField(): void;
  126401. /**
  126402. * Sets the Aperture amount
  126403. * @param amount amount of Aperture
  126404. */
  126405. setAperture(amount: number): void;
  126406. /**
  126407. * Sets the DarkenOutOfFocus amount
  126408. * @param amount amount of DarkenOutOfFocus
  126409. */
  126410. setDarkenOutOfFocus(amount: number): void;
  126411. private _pentagonBokehIsEnabled;
  126412. /**
  126413. * Creates a pentagon bokeh effect
  126414. */
  126415. enablePentagonBokeh(): void;
  126416. /**
  126417. * Disables the pentagon bokeh effect
  126418. */
  126419. disablePentagonBokeh(): void;
  126420. /**
  126421. * Enables noise blur
  126422. */
  126423. enableNoiseBlur(): void;
  126424. /**
  126425. * Disables noise blur
  126426. */
  126427. disableNoiseBlur(): void;
  126428. /**
  126429. * Sets the HighlightsGain amount
  126430. * @param amount amount of HighlightsGain
  126431. */
  126432. setHighlightsGain(amount: number): void;
  126433. /**
  126434. * Sets the HighlightsThreshold amount
  126435. * @param amount amount of HighlightsThreshold
  126436. */
  126437. setHighlightsThreshold(amount: number): void;
  126438. /**
  126439. * Disables highlights
  126440. */
  126441. disableHighlights(): void;
  126442. /**
  126443. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  126444. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  126445. */
  126446. dispose(disableDepthRender?: boolean): void;
  126447. private _createChromaticAberrationPostProcess;
  126448. private _createHighlightsPostProcess;
  126449. private _createDepthOfFieldPostProcess;
  126450. private _createGrainTexture;
  126451. }
  126452. }
  126453. declare module BABYLON {
  126454. /** @hidden */
  126455. export var ssao2PixelShader: {
  126456. name: string;
  126457. shader: string;
  126458. };
  126459. }
  126460. declare module BABYLON {
  126461. /** @hidden */
  126462. export var ssaoCombinePixelShader: {
  126463. name: string;
  126464. shader: string;
  126465. };
  126466. }
  126467. declare module BABYLON {
  126468. /**
  126469. * Render pipeline to produce ssao effect
  126470. */
  126471. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  126472. /**
  126473. * @ignore
  126474. * The PassPostProcess id in the pipeline that contains the original scene color
  126475. */
  126476. SSAOOriginalSceneColorEffect: string;
  126477. /**
  126478. * @ignore
  126479. * The SSAO PostProcess id in the pipeline
  126480. */
  126481. SSAORenderEffect: string;
  126482. /**
  126483. * @ignore
  126484. * The horizontal blur PostProcess id in the pipeline
  126485. */
  126486. SSAOBlurHRenderEffect: string;
  126487. /**
  126488. * @ignore
  126489. * The vertical blur PostProcess id in the pipeline
  126490. */
  126491. SSAOBlurVRenderEffect: string;
  126492. /**
  126493. * @ignore
  126494. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  126495. */
  126496. SSAOCombineRenderEffect: string;
  126497. /**
  126498. * The output strength of the SSAO post-process. Default value is 1.0.
  126499. */
  126500. totalStrength: number;
  126501. /**
  126502. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  126503. */
  126504. maxZ: number;
  126505. /**
  126506. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  126507. */
  126508. minZAspect: number;
  126509. private _samples;
  126510. /**
  126511. * Number of samples used for the SSAO calculations. Default value is 8
  126512. */
  126513. samples: number;
  126514. private _textureSamples;
  126515. /**
  126516. * Number of samples to use for antialiasing
  126517. */
  126518. textureSamples: number;
  126519. /**
  126520. * Ratio object used for SSAO ratio and blur ratio
  126521. */
  126522. private _ratio;
  126523. /**
  126524. * Dynamically generated sphere sampler.
  126525. */
  126526. private _sampleSphere;
  126527. /**
  126528. * Blur filter offsets
  126529. */
  126530. private _samplerOffsets;
  126531. private _expensiveBlur;
  126532. /**
  126533. * If bilateral blur should be used
  126534. */
  126535. expensiveBlur: boolean;
  126536. /**
  126537. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  126538. */
  126539. radius: number;
  126540. /**
  126541. * The base color of the SSAO post-process
  126542. * The final result is "base + ssao" between [0, 1]
  126543. */
  126544. base: number;
  126545. /**
  126546. * Support test.
  126547. */
  126548. static readonly IsSupported: boolean;
  126549. private _scene;
  126550. private _depthTexture;
  126551. private _normalTexture;
  126552. private _randomTexture;
  126553. private _originalColorPostProcess;
  126554. private _ssaoPostProcess;
  126555. private _blurHPostProcess;
  126556. private _blurVPostProcess;
  126557. private _ssaoCombinePostProcess;
  126558. private _firstUpdate;
  126559. /**
  126560. * Gets active scene
  126561. */
  126562. readonly scene: Scene;
  126563. /**
  126564. * @constructor
  126565. * @param name The rendering pipeline name
  126566. * @param scene The scene linked to this pipeline
  126567. * @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 }
  126568. * @param cameras The array of cameras that the rendering pipeline will be attached to
  126569. */
  126570. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  126571. /**
  126572. * Get the class name
  126573. * @returns "SSAO2RenderingPipeline"
  126574. */
  126575. getClassName(): string;
  126576. /**
  126577. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  126578. */
  126579. dispose(disableGeometryBufferRenderer?: boolean): void;
  126580. private _createBlurPostProcess;
  126581. /** @hidden */
  126582. _rebuild(): void;
  126583. private _bits;
  126584. private _radicalInverse_VdC;
  126585. private _hammersley;
  126586. private _hemisphereSample_uniform;
  126587. private _generateHemisphere;
  126588. private _createSSAOPostProcess;
  126589. private _createSSAOCombinePostProcess;
  126590. private _createRandomTexture;
  126591. /**
  126592. * Serialize the rendering pipeline (Used when exporting)
  126593. * @returns the serialized object
  126594. */
  126595. serialize(): any;
  126596. /**
  126597. * Parse the serialized pipeline
  126598. * @param source Source pipeline.
  126599. * @param scene The scene to load the pipeline to.
  126600. * @param rootUrl The URL of the serialized pipeline.
  126601. * @returns An instantiated pipeline from the serialized object.
  126602. */
  126603. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  126604. }
  126605. }
  126606. declare module BABYLON {
  126607. /** @hidden */
  126608. export var ssaoPixelShader: {
  126609. name: string;
  126610. shader: string;
  126611. };
  126612. }
  126613. declare module BABYLON {
  126614. /**
  126615. * Render pipeline to produce ssao effect
  126616. */
  126617. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  126618. /**
  126619. * @ignore
  126620. * The PassPostProcess id in the pipeline that contains the original scene color
  126621. */
  126622. SSAOOriginalSceneColorEffect: string;
  126623. /**
  126624. * @ignore
  126625. * The SSAO PostProcess id in the pipeline
  126626. */
  126627. SSAORenderEffect: string;
  126628. /**
  126629. * @ignore
  126630. * The horizontal blur PostProcess id in the pipeline
  126631. */
  126632. SSAOBlurHRenderEffect: string;
  126633. /**
  126634. * @ignore
  126635. * The vertical blur PostProcess id in the pipeline
  126636. */
  126637. SSAOBlurVRenderEffect: string;
  126638. /**
  126639. * @ignore
  126640. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  126641. */
  126642. SSAOCombineRenderEffect: string;
  126643. /**
  126644. * The output strength of the SSAO post-process. Default value is 1.0.
  126645. */
  126646. totalStrength: number;
  126647. /**
  126648. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  126649. */
  126650. radius: number;
  126651. /**
  126652. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  126653. * Must not be equal to fallOff and superior to fallOff.
  126654. * Default value is 0.0075
  126655. */
  126656. area: number;
  126657. /**
  126658. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  126659. * Must not be equal to area and inferior to area.
  126660. * Default value is 0.000001
  126661. */
  126662. fallOff: number;
  126663. /**
  126664. * The base color of the SSAO post-process
  126665. * The final result is "base + ssao" between [0, 1]
  126666. */
  126667. base: number;
  126668. private _scene;
  126669. private _depthTexture;
  126670. private _randomTexture;
  126671. private _originalColorPostProcess;
  126672. private _ssaoPostProcess;
  126673. private _blurHPostProcess;
  126674. private _blurVPostProcess;
  126675. private _ssaoCombinePostProcess;
  126676. private _firstUpdate;
  126677. /**
  126678. * Gets active scene
  126679. */
  126680. readonly scene: Scene;
  126681. /**
  126682. * @constructor
  126683. * @param name - The rendering pipeline name
  126684. * @param scene - The scene linked to this pipeline
  126685. * @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 }
  126686. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  126687. */
  126688. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  126689. /**
  126690. * Get the class name
  126691. * @returns "SSAORenderingPipeline"
  126692. */
  126693. getClassName(): string;
  126694. /**
  126695. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  126696. */
  126697. dispose(disableDepthRender?: boolean): void;
  126698. private _createBlurPostProcess;
  126699. /** @hidden */
  126700. _rebuild(): void;
  126701. private _createSSAOPostProcess;
  126702. private _createSSAOCombinePostProcess;
  126703. private _createRandomTexture;
  126704. }
  126705. }
  126706. declare module BABYLON {
  126707. /** @hidden */
  126708. export var standardPixelShader: {
  126709. name: string;
  126710. shader: string;
  126711. };
  126712. }
  126713. declare module BABYLON {
  126714. /**
  126715. * Standard rendering pipeline
  126716. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  126717. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  126718. */
  126719. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  126720. /**
  126721. * Public members
  126722. */
  126723. /**
  126724. * Post-process which contains the original scene color before the pipeline applies all the effects
  126725. */
  126726. originalPostProcess: Nullable<PostProcess>;
  126727. /**
  126728. * Post-process used to down scale an image x4
  126729. */
  126730. downSampleX4PostProcess: Nullable<PostProcess>;
  126731. /**
  126732. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  126733. */
  126734. brightPassPostProcess: Nullable<PostProcess>;
  126735. /**
  126736. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  126737. */
  126738. blurHPostProcesses: PostProcess[];
  126739. /**
  126740. * Post-process array storing all the vertical blur post-processes used by the pipeline
  126741. */
  126742. blurVPostProcesses: PostProcess[];
  126743. /**
  126744. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  126745. */
  126746. textureAdderPostProcess: Nullable<PostProcess>;
  126747. /**
  126748. * Post-process used to create volumetric lighting effect
  126749. */
  126750. volumetricLightPostProcess: Nullable<PostProcess>;
  126751. /**
  126752. * Post-process used to smooth the previous volumetric light post-process on the X axis
  126753. */
  126754. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  126755. /**
  126756. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  126757. */
  126758. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  126759. /**
  126760. * Post-process used to merge the volumetric light effect and the real scene color
  126761. */
  126762. volumetricLightMergePostProces: Nullable<PostProcess>;
  126763. /**
  126764. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  126765. */
  126766. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  126767. /**
  126768. * Base post-process used to calculate the average luminance of the final image for HDR
  126769. */
  126770. luminancePostProcess: Nullable<PostProcess>;
  126771. /**
  126772. * Post-processes used to create down sample post-processes in order to get
  126773. * the average luminance of the final image for HDR
  126774. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  126775. */
  126776. luminanceDownSamplePostProcesses: PostProcess[];
  126777. /**
  126778. * Post-process used to create a HDR effect (light adaptation)
  126779. */
  126780. hdrPostProcess: Nullable<PostProcess>;
  126781. /**
  126782. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  126783. */
  126784. textureAdderFinalPostProcess: Nullable<PostProcess>;
  126785. /**
  126786. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  126787. */
  126788. lensFlareFinalPostProcess: Nullable<PostProcess>;
  126789. /**
  126790. * Post-process used to merge the final HDR post-process and the real scene color
  126791. */
  126792. hdrFinalPostProcess: Nullable<PostProcess>;
  126793. /**
  126794. * Post-process used to create a lens flare effect
  126795. */
  126796. lensFlarePostProcess: Nullable<PostProcess>;
  126797. /**
  126798. * Post-process that merges the result of the lens flare post-process and the real scene color
  126799. */
  126800. lensFlareComposePostProcess: Nullable<PostProcess>;
  126801. /**
  126802. * Post-process used to create a motion blur effect
  126803. */
  126804. motionBlurPostProcess: Nullable<PostProcess>;
  126805. /**
  126806. * Post-process used to create a depth of field effect
  126807. */
  126808. depthOfFieldPostProcess: Nullable<PostProcess>;
  126809. /**
  126810. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  126811. */
  126812. fxaaPostProcess: Nullable<FxaaPostProcess>;
  126813. /**
  126814. * Represents the brightness threshold in order to configure the illuminated surfaces
  126815. */
  126816. brightThreshold: number;
  126817. /**
  126818. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  126819. */
  126820. blurWidth: number;
  126821. /**
  126822. * Sets if the blur for highlighted surfaces must be only horizontal
  126823. */
  126824. horizontalBlur: boolean;
  126825. /**
  126826. * Gets the overall exposure used by the pipeline
  126827. */
  126828. /**
  126829. * Sets the overall exposure used by the pipeline
  126830. */
  126831. exposure: number;
  126832. /**
  126833. * Texture used typically to simulate "dirty" on camera lens
  126834. */
  126835. lensTexture: Nullable<Texture>;
  126836. /**
  126837. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  126838. */
  126839. volumetricLightCoefficient: number;
  126840. /**
  126841. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  126842. */
  126843. volumetricLightPower: number;
  126844. /**
  126845. * Used the set the blur intensity to smooth the volumetric lights
  126846. */
  126847. volumetricLightBlurScale: number;
  126848. /**
  126849. * Light (spot or directional) used to generate the volumetric lights rays
  126850. * The source light must have a shadow generate so the pipeline can get its
  126851. * depth map
  126852. */
  126853. sourceLight: Nullable<SpotLight | DirectionalLight>;
  126854. /**
  126855. * For eye adaptation, represents the minimum luminance the eye can see
  126856. */
  126857. hdrMinimumLuminance: number;
  126858. /**
  126859. * For eye adaptation, represents the decrease luminance speed
  126860. */
  126861. hdrDecreaseRate: number;
  126862. /**
  126863. * For eye adaptation, represents the increase luminance speed
  126864. */
  126865. hdrIncreaseRate: number;
  126866. /**
  126867. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  126868. */
  126869. /**
  126870. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  126871. */
  126872. hdrAutoExposure: boolean;
  126873. /**
  126874. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  126875. */
  126876. lensColorTexture: Nullable<Texture>;
  126877. /**
  126878. * The overall strengh for the lens flare effect
  126879. */
  126880. lensFlareStrength: number;
  126881. /**
  126882. * Dispersion coefficient for lens flare ghosts
  126883. */
  126884. lensFlareGhostDispersal: number;
  126885. /**
  126886. * Main lens flare halo width
  126887. */
  126888. lensFlareHaloWidth: number;
  126889. /**
  126890. * Based on the lens distortion effect, defines how much the lens flare result
  126891. * is distorted
  126892. */
  126893. lensFlareDistortionStrength: number;
  126894. /**
  126895. * Configures the blur intensity used for for lens flare (halo)
  126896. */
  126897. lensFlareBlurWidth: number;
  126898. /**
  126899. * Lens star texture must be used to simulate rays on the flares and is available
  126900. * in the documentation
  126901. */
  126902. lensStarTexture: Nullable<Texture>;
  126903. /**
  126904. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  126905. * flare effect by taking account of the dirt texture
  126906. */
  126907. lensFlareDirtTexture: Nullable<Texture>;
  126908. /**
  126909. * Represents the focal length for the depth of field effect
  126910. */
  126911. depthOfFieldDistance: number;
  126912. /**
  126913. * Represents the blur intensity for the blurred part of the depth of field effect
  126914. */
  126915. depthOfFieldBlurWidth: number;
  126916. /**
  126917. * Gets how much the image is blurred by the movement while using the motion blur post-process
  126918. */
  126919. /**
  126920. * Sets how much the image is blurred by the movement while using the motion blur post-process
  126921. */
  126922. motionStrength: number;
  126923. /**
  126924. * Gets wether or not the motion blur post-process is object based or screen based.
  126925. */
  126926. /**
  126927. * Sets wether or not the motion blur post-process should be object based or screen based
  126928. */
  126929. objectBasedMotionBlur: boolean;
  126930. /**
  126931. * List of animations for the pipeline (IAnimatable implementation)
  126932. */
  126933. animations: Animation[];
  126934. /**
  126935. * Private members
  126936. */
  126937. private _scene;
  126938. private _currentDepthOfFieldSource;
  126939. private _basePostProcess;
  126940. private _fixedExposure;
  126941. private _currentExposure;
  126942. private _hdrAutoExposure;
  126943. private _hdrCurrentLuminance;
  126944. private _motionStrength;
  126945. private _isObjectBasedMotionBlur;
  126946. private _floatTextureType;
  126947. private _camerasToBeAttached;
  126948. private _ratio;
  126949. private _bloomEnabled;
  126950. private _depthOfFieldEnabled;
  126951. private _vlsEnabled;
  126952. private _lensFlareEnabled;
  126953. private _hdrEnabled;
  126954. private _motionBlurEnabled;
  126955. private _fxaaEnabled;
  126956. private _motionBlurSamples;
  126957. private _volumetricLightStepsCount;
  126958. private _samples;
  126959. /**
  126960. * @ignore
  126961. * Specifies if the bloom pipeline is enabled
  126962. */
  126963. BloomEnabled: boolean;
  126964. /**
  126965. * @ignore
  126966. * Specifies if the depth of field pipeline is enabed
  126967. */
  126968. DepthOfFieldEnabled: boolean;
  126969. /**
  126970. * @ignore
  126971. * Specifies if the lens flare pipeline is enabed
  126972. */
  126973. LensFlareEnabled: boolean;
  126974. /**
  126975. * @ignore
  126976. * Specifies if the HDR pipeline is enabled
  126977. */
  126978. HDREnabled: boolean;
  126979. /**
  126980. * @ignore
  126981. * Specifies if the volumetric lights scattering effect is enabled
  126982. */
  126983. VLSEnabled: boolean;
  126984. /**
  126985. * @ignore
  126986. * Specifies if the motion blur effect is enabled
  126987. */
  126988. MotionBlurEnabled: boolean;
  126989. /**
  126990. * Specifies if anti-aliasing is enabled
  126991. */
  126992. fxaaEnabled: boolean;
  126993. /**
  126994. * Specifies the number of steps used to calculate the volumetric lights
  126995. * Typically in interval [50, 200]
  126996. */
  126997. volumetricLightStepsCount: number;
  126998. /**
  126999. * Specifies the number of samples used for the motion blur effect
  127000. * Typically in interval [16, 64]
  127001. */
  127002. motionBlurSamples: number;
  127003. /**
  127004. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  127005. */
  127006. samples: number;
  127007. /**
  127008. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127009. * @constructor
  127010. * @param name The rendering pipeline name
  127011. * @param scene The scene linked to this pipeline
  127012. * @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)
  127013. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  127014. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127015. */
  127016. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  127017. private _buildPipeline;
  127018. private _createDownSampleX4PostProcess;
  127019. private _createBrightPassPostProcess;
  127020. private _createBlurPostProcesses;
  127021. private _createTextureAdderPostProcess;
  127022. private _createVolumetricLightPostProcess;
  127023. private _createLuminancePostProcesses;
  127024. private _createHdrPostProcess;
  127025. private _createLensFlarePostProcess;
  127026. private _createDepthOfFieldPostProcess;
  127027. private _createMotionBlurPostProcess;
  127028. private _getDepthTexture;
  127029. private _disposePostProcesses;
  127030. /**
  127031. * Dispose of the pipeline and stop all post processes
  127032. */
  127033. dispose(): void;
  127034. /**
  127035. * Serialize the rendering pipeline (Used when exporting)
  127036. * @returns the serialized object
  127037. */
  127038. serialize(): any;
  127039. /**
  127040. * Parse the serialized pipeline
  127041. * @param source Source pipeline.
  127042. * @param scene The scene to load the pipeline to.
  127043. * @param rootUrl The URL of the serialized pipeline.
  127044. * @returns An instantiated pipeline from the serialized object.
  127045. */
  127046. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  127047. /**
  127048. * Luminance steps
  127049. */
  127050. static LuminanceSteps: number;
  127051. }
  127052. }
  127053. declare module BABYLON {
  127054. /** @hidden */
  127055. export var tonemapPixelShader: {
  127056. name: string;
  127057. shader: string;
  127058. };
  127059. }
  127060. declare module BABYLON {
  127061. /** Defines operator used for tonemapping */
  127062. export enum TonemappingOperator {
  127063. /** Hable */
  127064. Hable = 0,
  127065. /** Reinhard */
  127066. Reinhard = 1,
  127067. /** HejiDawson */
  127068. HejiDawson = 2,
  127069. /** Photographic */
  127070. Photographic = 3
  127071. }
  127072. /**
  127073. * Defines a post process to apply tone mapping
  127074. */
  127075. export class TonemapPostProcess extends PostProcess {
  127076. private _operator;
  127077. /** Defines the required exposure adjustement */
  127078. exposureAdjustment: number;
  127079. /**
  127080. * Creates a new TonemapPostProcess
  127081. * @param name defines the name of the postprocess
  127082. * @param _operator defines the operator to use
  127083. * @param exposureAdjustment defines the required exposure adjustement
  127084. * @param camera defines the camera to use (can be null)
  127085. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  127086. * @param engine defines the hosting engine (can be ignore if camera is set)
  127087. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  127088. */
  127089. constructor(name: string, _operator: TonemappingOperator,
  127090. /** Defines the required exposure adjustement */
  127091. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  127092. }
  127093. }
  127094. declare module BABYLON {
  127095. /** @hidden */
  127096. export var depthVertexShader: {
  127097. name: string;
  127098. shader: string;
  127099. };
  127100. }
  127101. declare module BABYLON {
  127102. /** @hidden */
  127103. export var volumetricLightScatteringPixelShader: {
  127104. name: string;
  127105. shader: string;
  127106. };
  127107. }
  127108. declare module BABYLON {
  127109. /** @hidden */
  127110. export var volumetricLightScatteringPassVertexShader: {
  127111. name: string;
  127112. shader: string;
  127113. };
  127114. }
  127115. declare module BABYLON {
  127116. /** @hidden */
  127117. export var volumetricLightScatteringPassPixelShader: {
  127118. name: string;
  127119. shader: string;
  127120. };
  127121. }
  127122. declare module BABYLON {
  127123. /**
  127124. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  127125. */
  127126. export class VolumetricLightScatteringPostProcess extends PostProcess {
  127127. private _volumetricLightScatteringPass;
  127128. private _volumetricLightScatteringRTT;
  127129. private _viewPort;
  127130. private _screenCoordinates;
  127131. private _cachedDefines;
  127132. /**
  127133. * If not undefined, the mesh position is computed from the attached node position
  127134. */
  127135. attachedNode: {
  127136. position: Vector3;
  127137. };
  127138. /**
  127139. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  127140. */
  127141. customMeshPosition: Vector3;
  127142. /**
  127143. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  127144. */
  127145. useCustomMeshPosition: boolean;
  127146. /**
  127147. * If the post-process should inverse the light scattering direction
  127148. */
  127149. invert: boolean;
  127150. /**
  127151. * The internal mesh used by the post-process
  127152. */
  127153. mesh: Mesh;
  127154. /**
  127155. * @hidden
  127156. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  127157. */
  127158. useDiffuseColor: boolean;
  127159. /**
  127160. * Array containing the excluded meshes not rendered in the internal pass
  127161. */
  127162. excludedMeshes: AbstractMesh[];
  127163. /**
  127164. * Controls the overall intensity of the post-process
  127165. */
  127166. exposure: number;
  127167. /**
  127168. * Dissipates each sample's contribution in range [0, 1]
  127169. */
  127170. decay: number;
  127171. /**
  127172. * Controls the overall intensity of each sample
  127173. */
  127174. weight: number;
  127175. /**
  127176. * Controls the density of each sample
  127177. */
  127178. density: number;
  127179. /**
  127180. * @constructor
  127181. * @param name The post-process name
  127182. * @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)
  127183. * @param camera The camera that the post-process will be attached to
  127184. * @param mesh The mesh used to create the light scattering
  127185. * @param samples The post-process quality, default 100
  127186. * @param samplingModeThe post-process filtering mode
  127187. * @param engine The babylon engine
  127188. * @param reusable If the post-process is reusable
  127189. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  127190. */
  127191. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  127192. /**
  127193. * Returns the string "VolumetricLightScatteringPostProcess"
  127194. * @returns "VolumetricLightScatteringPostProcess"
  127195. */
  127196. getClassName(): string;
  127197. private _isReady;
  127198. /**
  127199. * Sets the new light position for light scattering effect
  127200. * @param position The new custom light position
  127201. */
  127202. setCustomMeshPosition(position: Vector3): void;
  127203. /**
  127204. * Returns the light position for light scattering effect
  127205. * @return Vector3 The custom light position
  127206. */
  127207. getCustomMeshPosition(): Vector3;
  127208. /**
  127209. * Disposes the internal assets and detaches the post-process from the camera
  127210. */
  127211. dispose(camera: Camera): void;
  127212. /**
  127213. * Returns the render target texture used by the post-process
  127214. * @return the render target texture used by the post-process
  127215. */
  127216. getPass(): RenderTargetTexture;
  127217. private _meshExcluded;
  127218. private _createPass;
  127219. private _updateMeshScreenCoordinates;
  127220. /**
  127221. * Creates a default mesh for the Volumeric Light Scattering post-process
  127222. * @param name The mesh name
  127223. * @param scene The scene where to create the mesh
  127224. * @return the default mesh
  127225. */
  127226. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  127227. }
  127228. }
  127229. declare module BABYLON {
  127230. interface Scene {
  127231. /** @hidden (Backing field) */
  127232. _boundingBoxRenderer: BoundingBoxRenderer;
  127233. /** @hidden (Backing field) */
  127234. _forceShowBoundingBoxes: boolean;
  127235. /**
  127236. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  127237. */
  127238. forceShowBoundingBoxes: boolean;
  127239. /**
  127240. * Gets the bounding box renderer associated with the scene
  127241. * @returns a BoundingBoxRenderer
  127242. */
  127243. getBoundingBoxRenderer(): BoundingBoxRenderer;
  127244. }
  127245. interface AbstractMesh {
  127246. /** @hidden (Backing field) */
  127247. _showBoundingBox: boolean;
  127248. /**
  127249. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  127250. */
  127251. showBoundingBox: boolean;
  127252. }
  127253. /**
  127254. * Component responsible of rendering the bounding box of the meshes in a scene.
  127255. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  127256. */
  127257. export class BoundingBoxRenderer implements ISceneComponent {
  127258. /**
  127259. * The component name helpfull to identify the component in the list of scene components.
  127260. */
  127261. readonly name: string;
  127262. /**
  127263. * The scene the component belongs to.
  127264. */
  127265. scene: Scene;
  127266. /**
  127267. * Color of the bounding box lines placed in front of an object
  127268. */
  127269. frontColor: Color3;
  127270. /**
  127271. * Color of the bounding box lines placed behind an object
  127272. */
  127273. backColor: Color3;
  127274. /**
  127275. * Defines if the renderer should show the back lines or not
  127276. */
  127277. showBackLines: boolean;
  127278. /**
  127279. * @hidden
  127280. */
  127281. renderList: SmartArray<BoundingBox>;
  127282. private _colorShader;
  127283. private _vertexBuffers;
  127284. private _indexBuffer;
  127285. private _fillIndexBuffer;
  127286. private _fillIndexData;
  127287. /**
  127288. * Instantiates a new bounding box renderer in a scene.
  127289. * @param scene the scene the renderer renders in
  127290. */
  127291. constructor(scene: Scene);
  127292. /**
  127293. * Registers the component in a given scene
  127294. */
  127295. register(): void;
  127296. private _evaluateSubMesh;
  127297. private _activeMesh;
  127298. private _prepareRessources;
  127299. private _createIndexBuffer;
  127300. /**
  127301. * Rebuilds the elements related to this component in case of
  127302. * context lost for instance.
  127303. */
  127304. rebuild(): void;
  127305. /**
  127306. * @hidden
  127307. */
  127308. reset(): void;
  127309. /**
  127310. * Render the bounding boxes of a specific rendering group
  127311. * @param renderingGroupId defines the rendering group to render
  127312. */
  127313. render(renderingGroupId: number): void;
  127314. /**
  127315. * In case of occlusion queries, we can render the occlusion bounding box through this method
  127316. * @param mesh Define the mesh to render the occlusion bounding box for
  127317. */
  127318. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  127319. /**
  127320. * Dispose and release the resources attached to this renderer.
  127321. */
  127322. dispose(): void;
  127323. }
  127324. }
  127325. declare module BABYLON {
  127326. /** @hidden */
  127327. export var depthPixelShader: {
  127328. name: string;
  127329. shader: string;
  127330. };
  127331. }
  127332. declare module BABYLON {
  127333. /**
  127334. * This represents a depth renderer in Babylon.
  127335. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127336. */
  127337. export class DepthRenderer {
  127338. private _scene;
  127339. private _depthMap;
  127340. private _effect;
  127341. private readonly _storeNonLinearDepth;
  127342. private readonly _clearColor;
  127343. /** Get if the depth renderer is using packed depth or not */
  127344. readonly isPacked: boolean;
  127345. private _cachedDefines;
  127346. private _camera;
  127347. /**
  127348. * Specifiess that the depth renderer will only be used within
  127349. * the camera it is created for.
  127350. * This can help forcing its rendering during the camera processing.
  127351. */
  127352. useOnlyInActiveCamera: boolean;
  127353. /** @hidden */
  127354. static _SceneComponentInitialization: (scene: Scene) => void;
  127355. /**
  127356. * Instantiates a depth renderer
  127357. * @param scene The scene the renderer belongs to
  127358. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127359. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127360. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127361. */
  127362. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127363. /**
  127364. * Creates the depth rendering effect and checks if the effect is ready.
  127365. * @param subMesh The submesh to be used to render the depth map of
  127366. * @param useInstances If multiple world instances should be used
  127367. * @returns if the depth renderer is ready to render the depth map
  127368. */
  127369. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127370. /**
  127371. * Gets the texture which the depth map will be written to.
  127372. * @returns The depth map texture
  127373. */
  127374. getDepthMap(): RenderTargetTexture;
  127375. /**
  127376. * Disposes of the depth renderer.
  127377. */
  127378. dispose(): void;
  127379. }
  127380. }
  127381. declare module BABYLON {
  127382. interface Scene {
  127383. /** @hidden (Backing field) */
  127384. _depthRenderer: {
  127385. [id: string]: DepthRenderer;
  127386. };
  127387. /**
  127388. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  127389. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  127390. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127391. * @returns the created depth renderer
  127392. */
  127393. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  127394. /**
  127395. * Disables a depth renderer for a given camera
  127396. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  127397. */
  127398. disableDepthRenderer(camera?: Nullable<Camera>): void;
  127399. }
  127400. /**
  127401. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  127402. * in several rendering techniques.
  127403. */
  127404. export class DepthRendererSceneComponent implements ISceneComponent {
  127405. /**
  127406. * The component name helpfull to identify the component in the list of scene components.
  127407. */
  127408. readonly name: string;
  127409. /**
  127410. * The scene the component belongs to.
  127411. */
  127412. scene: Scene;
  127413. /**
  127414. * Creates a new instance of the component for the given scene
  127415. * @param scene Defines the scene to register the component in
  127416. */
  127417. constructor(scene: Scene);
  127418. /**
  127419. * Registers the component in a given scene
  127420. */
  127421. register(): void;
  127422. /**
  127423. * Rebuilds the elements related to this component in case of
  127424. * context lost for instance.
  127425. */
  127426. rebuild(): void;
  127427. /**
  127428. * Disposes the component and the associated ressources
  127429. */
  127430. dispose(): void;
  127431. private _gatherRenderTargets;
  127432. private _gatherActiveCameraRenderTargets;
  127433. }
  127434. }
  127435. declare module BABYLON {
  127436. /** @hidden */
  127437. export var outlinePixelShader: {
  127438. name: string;
  127439. shader: string;
  127440. };
  127441. }
  127442. declare module BABYLON {
  127443. /** @hidden */
  127444. export var outlineVertexShader: {
  127445. name: string;
  127446. shader: string;
  127447. };
  127448. }
  127449. declare module BABYLON {
  127450. interface Scene {
  127451. /** @hidden */
  127452. _outlineRenderer: OutlineRenderer;
  127453. /**
  127454. * Gets the outline renderer associated with the scene
  127455. * @returns a OutlineRenderer
  127456. */
  127457. getOutlineRenderer(): OutlineRenderer;
  127458. }
  127459. interface AbstractMesh {
  127460. /** @hidden (Backing field) */
  127461. _renderOutline: boolean;
  127462. /**
  127463. * Gets or sets a boolean indicating if the outline must be rendered as well
  127464. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  127465. */
  127466. renderOutline: boolean;
  127467. /** @hidden (Backing field) */
  127468. _renderOverlay: boolean;
  127469. /**
  127470. * Gets or sets a boolean indicating if the overlay must be rendered as well
  127471. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  127472. */
  127473. renderOverlay: boolean;
  127474. }
  127475. /**
  127476. * This class is responsible to draw bothe outline/overlay of meshes.
  127477. * It should not be used directly but through the available method on mesh.
  127478. */
  127479. export class OutlineRenderer implements ISceneComponent {
  127480. /**
  127481. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  127482. */
  127483. private static _StencilReference;
  127484. /**
  127485. * The name of the component. Each component must have a unique name.
  127486. */
  127487. name: string;
  127488. /**
  127489. * The scene the component belongs to.
  127490. */
  127491. scene: Scene;
  127492. /**
  127493. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  127494. */
  127495. zOffset: number;
  127496. private _engine;
  127497. private _effect;
  127498. private _cachedDefines;
  127499. private _savedDepthWrite;
  127500. /**
  127501. * Instantiates a new outline renderer. (There could be only one per scene).
  127502. * @param scene Defines the scene it belongs to
  127503. */
  127504. constructor(scene: Scene);
  127505. /**
  127506. * Register the component to one instance of a scene.
  127507. */
  127508. register(): void;
  127509. /**
  127510. * Rebuilds the elements related to this component in case of
  127511. * context lost for instance.
  127512. */
  127513. rebuild(): void;
  127514. /**
  127515. * Disposes the component and the associated ressources.
  127516. */
  127517. dispose(): void;
  127518. /**
  127519. * Renders the outline in the canvas.
  127520. * @param subMesh Defines the sumesh to render
  127521. * @param batch Defines the batch of meshes in case of instances
  127522. * @param useOverlay Defines if the rendering is for the overlay or the outline
  127523. */
  127524. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  127525. /**
  127526. * Returns whether or not the outline renderer is ready for a given submesh.
  127527. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  127528. * @param subMesh Defines the submesh to check readyness for
  127529. * @param useInstances Defines wheter wee are trying to render instances or not
  127530. * @returns true if ready otherwise false
  127531. */
  127532. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127533. private _beforeRenderingMesh;
  127534. private _afterRenderingMesh;
  127535. }
  127536. }
  127537. declare module BABYLON {
  127538. /**
  127539. * Class used to manage multiple sprites of different sizes on the same spritesheet
  127540. * @see http://doc.babylonjs.com/babylon101/sprites
  127541. */
  127542. export class SpritePackedManager extends SpriteManager {
  127543. /** defines the packed manager's name */
  127544. name: string;
  127545. /**
  127546. * Creates a new sprite manager from a packed sprite sheet
  127547. * @param name defines the manager's name
  127548. * @param imgUrl defines the sprite sheet url
  127549. * @param capacity defines the maximum allowed number of sprites
  127550. * @param scene defines the hosting scene
  127551. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  127552. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  127553. * @param samplingMode defines the smapling mode to use with spritesheet
  127554. * @param fromPacked set to true; do not alter
  127555. */
  127556. constructor(
  127557. /** defines the packed manager's name */
  127558. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  127559. }
  127560. }
  127561. declare module BABYLON {
  127562. /**
  127563. * Defines the list of states available for a task inside a AssetsManager
  127564. */
  127565. export enum AssetTaskState {
  127566. /**
  127567. * Initialization
  127568. */
  127569. INIT = 0,
  127570. /**
  127571. * Running
  127572. */
  127573. RUNNING = 1,
  127574. /**
  127575. * Done
  127576. */
  127577. DONE = 2,
  127578. /**
  127579. * Error
  127580. */
  127581. ERROR = 3
  127582. }
  127583. /**
  127584. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  127585. */
  127586. export abstract class AbstractAssetTask {
  127587. /**
  127588. * Task name
  127589. */ name: string;
  127590. /**
  127591. * Callback called when the task is successful
  127592. */
  127593. onSuccess: (task: any) => void;
  127594. /**
  127595. * Callback called when the task is not successful
  127596. */
  127597. onError: (task: any, message?: string, exception?: any) => void;
  127598. /**
  127599. * Creates a new AssetsManager
  127600. * @param name defines the name of the task
  127601. */
  127602. constructor(
  127603. /**
  127604. * Task name
  127605. */ name: string);
  127606. private _isCompleted;
  127607. private _taskState;
  127608. private _errorObject;
  127609. /**
  127610. * Get if the task is completed
  127611. */
  127612. readonly isCompleted: boolean;
  127613. /**
  127614. * Gets the current state of the task
  127615. */
  127616. readonly taskState: AssetTaskState;
  127617. /**
  127618. * Gets the current error object (if task is in error)
  127619. */
  127620. readonly errorObject: {
  127621. message?: string;
  127622. exception?: any;
  127623. };
  127624. /**
  127625. * Internal only
  127626. * @hidden
  127627. */
  127628. _setErrorObject(message?: string, exception?: any): void;
  127629. /**
  127630. * Execute the current task
  127631. * @param scene defines the scene where you want your assets to be loaded
  127632. * @param onSuccess is a callback called when the task is successfully executed
  127633. * @param onError is a callback called if an error occurs
  127634. */
  127635. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127636. /**
  127637. * Execute the current task
  127638. * @param scene defines the scene where you want your assets to be loaded
  127639. * @param onSuccess is a callback called when the task is successfully executed
  127640. * @param onError is a callback called if an error occurs
  127641. */
  127642. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127643. /**
  127644. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  127645. * This can be used with failed tasks that have the reason for failure fixed.
  127646. */
  127647. reset(): void;
  127648. private onErrorCallback;
  127649. private onDoneCallback;
  127650. }
  127651. /**
  127652. * Define the interface used by progress events raised during assets loading
  127653. */
  127654. export interface IAssetsProgressEvent {
  127655. /**
  127656. * Defines the number of remaining tasks to process
  127657. */
  127658. remainingCount: number;
  127659. /**
  127660. * Defines the total number of tasks
  127661. */
  127662. totalCount: number;
  127663. /**
  127664. * Defines the task that was just processed
  127665. */
  127666. task: AbstractAssetTask;
  127667. }
  127668. /**
  127669. * Class used to share progress information about assets loading
  127670. */
  127671. export class AssetsProgressEvent implements IAssetsProgressEvent {
  127672. /**
  127673. * Defines the number of remaining tasks to process
  127674. */
  127675. remainingCount: number;
  127676. /**
  127677. * Defines the total number of tasks
  127678. */
  127679. totalCount: number;
  127680. /**
  127681. * Defines the task that was just processed
  127682. */
  127683. task: AbstractAssetTask;
  127684. /**
  127685. * Creates a AssetsProgressEvent
  127686. * @param remainingCount defines the number of remaining tasks to process
  127687. * @param totalCount defines the total number of tasks
  127688. * @param task defines the task that was just processed
  127689. */
  127690. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  127691. }
  127692. /**
  127693. * Define a task used by AssetsManager to load meshes
  127694. */
  127695. export class MeshAssetTask extends AbstractAssetTask {
  127696. /**
  127697. * Defines the name of the task
  127698. */
  127699. name: string;
  127700. /**
  127701. * Defines the list of mesh's names you want to load
  127702. */
  127703. meshesNames: any;
  127704. /**
  127705. * Defines the root url to use as a base to load your meshes and associated resources
  127706. */
  127707. rootUrl: string;
  127708. /**
  127709. * Defines the filename of the scene to load from
  127710. */
  127711. sceneFilename: string;
  127712. /**
  127713. * Gets the list of loaded meshes
  127714. */
  127715. loadedMeshes: Array<AbstractMesh>;
  127716. /**
  127717. * Gets the list of loaded particle systems
  127718. */
  127719. loadedParticleSystems: Array<IParticleSystem>;
  127720. /**
  127721. * Gets the list of loaded skeletons
  127722. */
  127723. loadedSkeletons: Array<Skeleton>;
  127724. /**
  127725. * Gets the list of loaded animation groups
  127726. */
  127727. loadedAnimationGroups: Array<AnimationGroup>;
  127728. /**
  127729. * Callback called when the task is successful
  127730. */
  127731. onSuccess: (task: MeshAssetTask) => void;
  127732. /**
  127733. * Callback called when the task is successful
  127734. */
  127735. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  127736. /**
  127737. * Creates a new MeshAssetTask
  127738. * @param name defines the name of the task
  127739. * @param meshesNames defines the list of mesh's names you want to load
  127740. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  127741. * @param sceneFilename defines the filename of the scene to load from
  127742. */
  127743. constructor(
  127744. /**
  127745. * Defines the name of the task
  127746. */
  127747. name: string,
  127748. /**
  127749. * Defines the list of mesh's names you want to load
  127750. */
  127751. meshesNames: any,
  127752. /**
  127753. * Defines the root url to use as a base to load your meshes and associated resources
  127754. */
  127755. rootUrl: string,
  127756. /**
  127757. * Defines the filename of the scene to load from
  127758. */
  127759. sceneFilename: string);
  127760. /**
  127761. * Execute the current task
  127762. * @param scene defines the scene where you want your assets to be loaded
  127763. * @param onSuccess is a callback called when the task is successfully executed
  127764. * @param onError is a callback called if an error occurs
  127765. */
  127766. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127767. }
  127768. /**
  127769. * Define a task used by AssetsManager to load text content
  127770. */
  127771. export class TextFileAssetTask extends AbstractAssetTask {
  127772. /**
  127773. * Defines the name of the task
  127774. */
  127775. name: string;
  127776. /**
  127777. * Defines the location of the file to load
  127778. */
  127779. url: string;
  127780. /**
  127781. * Gets the loaded text string
  127782. */
  127783. text: string;
  127784. /**
  127785. * Callback called when the task is successful
  127786. */
  127787. onSuccess: (task: TextFileAssetTask) => void;
  127788. /**
  127789. * Callback called when the task is successful
  127790. */
  127791. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  127792. /**
  127793. * Creates a new TextFileAssetTask object
  127794. * @param name defines the name of the task
  127795. * @param url defines the location of the file to load
  127796. */
  127797. constructor(
  127798. /**
  127799. * Defines the name of the task
  127800. */
  127801. name: string,
  127802. /**
  127803. * Defines the location of the file to load
  127804. */
  127805. url: string);
  127806. /**
  127807. * Execute the current task
  127808. * @param scene defines the scene where you want your assets to be loaded
  127809. * @param onSuccess is a callback called when the task is successfully executed
  127810. * @param onError is a callback called if an error occurs
  127811. */
  127812. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127813. }
  127814. /**
  127815. * Define a task used by AssetsManager to load binary data
  127816. */
  127817. export class BinaryFileAssetTask extends AbstractAssetTask {
  127818. /**
  127819. * Defines the name of the task
  127820. */
  127821. name: string;
  127822. /**
  127823. * Defines the location of the file to load
  127824. */
  127825. url: string;
  127826. /**
  127827. * Gets the lodaded data (as an array buffer)
  127828. */
  127829. data: ArrayBuffer;
  127830. /**
  127831. * Callback called when the task is successful
  127832. */
  127833. onSuccess: (task: BinaryFileAssetTask) => void;
  127834. /**
  127835. * Callback called when the task is successful
  127836. */
  127837. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  127838. /**
  127839. * Creates a new BinaryFileAssetTask object
  127840. * @param name defines the name of the new task
  127841. * @param url defines the location of the file to load
  127842. */
  127843. constructor(
  127844. /**
  127845. * Defines the name of the task
  127846. */
  127847. name: string,
  127848. /**
  127849. * Defines the location of the file to load
  127850. */
  127851. url: string);
  127852. /**
  127853. * Execute the current task
  127854. * @param scene defines the scene where you want your assets to be loaded
  127855. * @param onSuccess is a callback called when the task is successfully executed
  127856. * @param onError is a callback called if an error occurs
  127857. */
  127858. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127859. }
  127860. /**
  127861. * Define a task used by AssetsManager to load images
  127862. */
  127863. export class ImageAssetTask extends AbstractAssetTask {
  127864. /**
  127865. * Defines the name of the task
  127866. */
  127867. name: string;
  127868. /**
  127869. * Defines the location of the image to load
  127870. */
  127871. url: string;
  127872. /**
  127873. * Gets the loaded images
  127874. */
  127875. image: HTMLImageElement;
  127876. /**
  127877. * Callback called when the task is successful
  127878. */
  127879. onSuccess: (task: ImageAssetTask) => void;
  127880. /**
  127881. * Callback called when the task is successful
  127882. */
  127883. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  127884. /**
  127885. * Creates a new ImageAssetTask
  127886. * @param name defines the name of the task
  127887. * @param url defines the location of the image to load
  127888. */
  127889. constructor(
  127890. /**
  127891. * Defines the name of the task
  127892. */
  127893. name: string,
  127894. /**
  127895. * Defines the location of the image to load
  127896. */
  127897. url: string);
  127898. /**
  127899. * Execute the current task
  127900. * @param scene defines the scene where you want your assets to be loaded
  127901. * @param onSuccess is a callback called when the task is successfully executed
  127902. * @param onError is a callback called if an error occurs
  127903. */
  127904. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127905. }
  127906. /**
  127907. * Defines the interface used by texture loading tasks
  127908. */
  127909. export interface ITextureAssetTask<TEX extends BaseTexture> {
  127910. /**
  127911. * Gets the loaded texture
  127912. */
  127913. texture: TEX;
  127914. }
  127915. /**
  127916. * Define a task used by AssetsManager to load 2D textures
  127917. */
  127918. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  127919. /**
  127920. * Defines the name of the task
  127921. */
  127922. name: string;
  127923. /**
  127924. * Defines the location of the file to load
  127925. */
  127926. url: string;
  127927. /**
  127928. * Defines if mipmap should not be generated (default is false)
  127929. */
  127930. noMipmap?: boolean | undefined;
  127931. /**
  127932. * Defines if texture must be inverted on Y axis (default is false)
  127933. */
  127934. invertY?: boolean | undefined;
  127935. /**
  127936. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  127937. */
  127938. samplingMode: number;
  127939. /**
  127940. * Gets the loaded texture
  127941. */
  127942. texture: Texture;
  127943. /**
  127944. * Callback called when the task is successful
  127945. */
  127946. onSuccess: (task: TextureAssetTask) => void;
  127947. /**
  127948. * Callback called when the task is successful
  127949. */
  127950. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  127951. /**
  127952. * Creates a new TextureAssetTask object
  127953. * @param name defines the name of the task
  127954. * @param url defines the location of the file to load
  127955. * @param noMipmap defines if mipmap should not be generated (default is false)
  127956. * @param invertY defines if texture must be inverted on Y axis (default is false)
  127957. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  127958. */
  127959. constructor(
  127960. /**
  127961. * Defines the name of the task
  127962. */
  127963. name: string,
  127964. /**
  127965. * Defines the location of the file to load
  127966. */
  127967. url: string,
  127968. /**
  127969. * Defines if mipmap should not be generated (default is false)
  127970. */
  127971. noMipmap?: boolean | undefined,
  127972. /**
  127973. * Defines if texture must be inverted on Y axis (default is false)
  127974. */
  127975. invertY?: boolean | undefined,
  127976. /**
  127977. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  127978. */
  127979. samplingMode?: number);
  127980. /**
  127981. * Execute the current task
  127982. * @param scene defines the scene where you want your assets to be loaded
  127983. * @param onSuccess is a callback called when the task is successfully executed
  127984. * @param onError is a callback called if an error occurs
  127985. */
  127986. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127987. }
  127988. /**
  127989. * Define a task used by AssetsManager to load cube textures
  127990. */
  127991. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  127992. /**
  127993. * Defines the name of the task
  127994. */
  127995. name: string;
  127996. /**
  127997. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  127998. */
  127999. url: string;
  128000. /**
  128001. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128002. */
  128003. extensions?: string[] | undefined;
  128004. /**
  128005. * Defines if mipmaps should not be generated (default is false)
  128006. */
  128007. noMipmap?: boolean | undefined;
  128008. /**
  128009. * Defines the explicit list of files (undefined by default)
  128010. */
  128011. files?: string[] | undefined;
  128012. /**
  128013. * Gets the loaded texture
  128014. */
  128015. texture: CubeTexture;
  128016. /**
  128017. * Callback called when the task is successful
  128018. */
  128019. onSuccess: (task: CubeTextureAssetTask) => void;
  128020. /**
  128021. * Callback called when the task is successful
  128022. */
  128023. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  128024. /**
  128025. * Creates a new CubeTextureAssetTask
  128026. * @param name defines the name of the task
  128027. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128028. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128029. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128030. * @param files defines the explicit list of files (undefined by default)
  128031. */
  128032. constructor(
  128033. /**
  128034. * Defines the name of the task
  128035. */
  128036. name: string,
  128037. /**
  128038. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128039. */
  128040. url: string,
  128041. /**
  128042. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128043. */
  128044. extensions?: string[] | undefined,
  128045. /**
  128046. * Defines if mipmaps should not be generated (default is false)
  128047. */
  128048. noMipmap?: boolean | undefined,
  128049. /**
  128050. * Defines the explicit list of files (undefined by default)
  128051. */
  128052. files?: string[] | undefined);
  128053. /**
  128054. * Execute the current task
  128055. * @param scene defines the scene where you want your assets to be loaded
  128056. * @param onSuccess is a callback called when the task is successfully executed
  128057. * @param onError is a callback called if an error occurs
  128058. */
  128059. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128060. }
  128061. /**
  128062. * Define a task used by AssetsManager to load HDR cube textures
  128063. */
  128064. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  128065. /**
  128066. * Defines the name of the task
  128067. */
  128068. name: string;
  128069. /**
  128070. * Defines the location of the file to load
  128071. */
  128072. url: string;
  128073. /**
  128074. * Defines the desired size (the more it increases the longer the generation will be)
  128075. */
  128076. size: number;
  128077. /**
  128078. * Defines if mipmaps should not be generated (default is false)
  128079. */
  128080. noMipmap: boolean;
  128081. /**
  128082. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128083. */
  128084. generateHarmonics: boolean;
  128085. /**
  128086. * 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)
  128087. */
  128088. gammaSpace: boolean;
  128089. /**
  128090. * Internal Use Only
  128091. */
  128092. reserved: boolean;
  128093. /**
  128094. * Gets the loaded texture
  128095. */
  128096. texture: HDRCubeTexture;
  128097. /**
  128098. * Callback called when the task is successful
  128099. */
  128100. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  128101. /**
  128102. * Callback called when the task is successful
  128103. */
  128104. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  128105. /**
  128106. * Creates a new HDRCubeTextureAssetTask object
  128107. * @param name defines the name of the task
  128108. * @param url defines the location of the file to load
  128109. * @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.
  128110. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128111. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128112. * @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)
  128113. * @param reserved Internal use only
  128114. */
  128115. constructor(
  128116. /**
  128117. * Defines the name of the task
  128118. */
  128119. name: string,
  128120. /**
  128121. * Defines the location of the file to load
  128122. */
  128123. url: string,
  128124. /**
  128125. * Defines the desired size (the more it increases the longer the generation will be)
  128126. */
  128127. size: number,
  128128. /**
  128129. * Defines if mipmaps should not be generated (default is false)
  128130. */
  128131. noMipmap?: boolean,
  128132. /**
  128133. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128134. */
  128135. generateHarmonics?: boolean,
  128136. /**
  128137. * 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)
  128138. */
  128139. gammaSpace?: boolean,
  128140. /**
  128141. * Internal Use Only
  128142. */
  128143. reserved?: boolean);
  128144. /**
  128145. * Execute the current task
  128146. * @param scene defines the scene where you want your assets to be loaded
  128147. * @param onSuccess is a callback called when the task is successfully executed
  128148. * @param onError is a callback called if an error occurs
  128149. */
  128150. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128151. }
  128152. /**
  128153. * Define a task used by AssetsManager to load Equirectangular cube textures
  128154. */
  128155. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  128156. /**
  128157. * Defines the name of the task
  128158. */
  128159. name: string;
  128160. /**
  128161. * Defines the location of the file to load
  128162. */
  128163. url: string;
  128164. /**
  128165. * Defines the desired size (the more it increases the longer the generation will be)
  128166. */
  128167. size: number;
  128168. /**
  128169. * Defines if mipmaps should not be generated (default is false)
  128170. */
  128171. noMipmap: boolean;
  128172. /**
  128173. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  128174. * but the standard material would require them in Gamma space) (default is true)
  128175. */
  128176. gammaSpace: boolean;
  128177. /**
  128178. * Gets the loaded texture
  128179. */
  128180. texture: EquiRectangularCubeTexture;
  128181. /**
  128182. * Callback called when the task is successful
  128183. */
  128184. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  128185. /**
  128186. * Callback called when the task is successful
  128187. */
  128188. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  128189. /**
  128190. * Creates a new EquiRectangularCubeTextureAssetTask object
  128191. * @param name defines the name of the task
  128192. * @param url defines the location of the file to load
  128193. * @param size defines the desired size (the more it increases the longer the generation will be)
  128194. * If the size is omitted this implies you are using a preprocessed cubemap.
  128195. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128196. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  128197. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  128198. * (default is true)
  128199. */
  128200. constructor(
  128201. /**
  128202. * Defines the name of the task
  128203. */
  128204. name: string,
  128205. /**
  128206. * Defines the location of the file to load
  128207. */
  128208. url: string,
  128209. /**
  128210. * Defines the desired size (the more it increases the longer the generation will be)
  128211. */
  128212. size: number,
  128213. /**
  128214. * Defines if mipmaps should not be generated (default is false)
  128215. */
  128216. noMipmap?: boolean,
  128217. /**
  128218. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  128219. * but the standard material would require them in Gamma space) (default is true)
  128220. */
  128221. gammaSpace?: boolean);
  128222. /**
  128223. * Execute the current task
  128224. * @param scene defines the scene where you want your assets to be loaded
  128225. * @param onSuccess is a callback called when the task is successfully executed
  128226. * @param onError is a callback called if an error occurs
  128227. */
  128228. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128229. }
  128230. /**
  128231. * This class can be used to easily import assets into a scene
  128232. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  128233. */
  128234. export class AssetsManager {
  128235. private _scene;
  128236. private _isLoading;
  128237. protected _tasks: AbstractAssetTask[];
  128238. protected _waitingTasksCount: number;
  128239. protected _totalTasksCount: number;
  128240. /**
  128241. * Callback called when all tasks are processed
  128242. */
  128243. onFinish: (tasks: AbstractAssetTask[]) => void;
  128244. /**
  128245. * Callback called when a task is successful
  128246. */
  128247. onTaskSuccess: (task: AbstractAssetTask) => void;
  128248. /**
  128249. * Callback called when a task had an error
  128250. */
  128251. onTaskError: (task: AbstractAssetTask) => void;
  128252. /**
  128253. * Callback called when a task is done (whatever the result is)
  128254. */
  128255. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  128256. /**
  128257. * Observable called when all tasks are processed
  128258. */
  128259. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  128260. /**
  128261. * Observable called when a task had an error
  128262. */
  128263. onTaskErrorObservable: Observable<AbstractAssetTask>;
  128264. /**
  128265. * Observable called when all tasks were executed
  128266. */
  128267. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  128268. /**
  128269. * Observable called when a task is done (whatever the result is)
  128270. */
  128271. onProgressObservable: Observable<IAssetsProgressEvent>;
  128272. /**
  128273. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  128274. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  128275. */
  128276. useDefaultLoadingScreen: boolean;
  128277. /**
  128278. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  128279. * when all assets have been downloaded.
  128280. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  128281. */
  128282. autoHideLoadingUI: boolean;
  128283. /**
  128284. * Creates a new AssetsManager
  128285. * @param scene defines the scene to work on
  128286. */
  128287. constructor(scene: Scene);
  128288. /**
  128289. * Add a MeshAssetTask to the list of active tasks
  128290. * @param taskName defines the name of the new task
  128291. * @param meshesNames defines the name of meshes to load
  128292. * @param rootUrl defines the root url to use to locate files
  128293. * @param sceneFilename defines the filename of the scene file
  128294. * @returns a new MeshAssetTask object
  128295. */
  128296. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  128297. /**
  128298. * Add a TextFileAssetTask to the list of active tasks
  128299. * @param taskName defines the name of the new task
  128300. * @param url defines the url of the file to load
  128301. * @returns a new TextFileAssetTask object
  128302. */
  128303. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  128304. /**
  128305. * Add a BinaryFileAssetTask to the list of active tasks
  128306. * @param taskName defines the name of the new task
  128307. * @param url defines the url of the file to load
  128308. * @returns a new BinaryFileAssetTask object
  128309. */
  128310. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  128311. /**
  128312. * Add a ImageAssetTask to the list of active tasks
  128313. * @param taskName defines the name of the new task
  128314. * @param url defines the url of the file to load
  128315. * @returns a new ImageAssetTask object
  128316. */
  128317. addImageTask(taskName: string, url: string): ImageAssetTask;
  128318. /**
  128319. * Add a TextureAssetTask to the list of active tasks
  128320. * @param taskName defines the name of the new task
  128321. * @param url defines the url of the file to load
  128322. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128323. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  128324. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  128325. * @returns a new TextureAssetTask object
  128326. */
  128327. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  128328. /**
  128329. * Add a CubeTextureAssetTask to the list of active tasks
  128330. * @param taskName defines the name of the new task
  128331. * @param url defines the url of the file to load
  128332. * @param extensions defines the extension to use to load the cube map (can be null)
  128333. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128334. * @param files defines the list of files to load (can be null)
  128335. * @returns a new CubeTextureAssetTask object
  128336. */
  128337. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  128338. /**
  128339. *
  128340. * Add a HDRCubeTextureAssetTask 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. * @param size defines the size you want for the cubemap (can be null)
  128344. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128345. * @param generateHarmonics defines if you want to automatically generate (true by default)
  128346. * @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)
  128347. * @param reserved Internal use only
  128348. * @returns a new HDRCubeTextureAssetTask object
  128349. */
  128350. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  128351. /**
  128352. *
  128353. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  128354. * @param taskName defines the name of the new task
  128355. * @param url defines the url of the file to load
  128356. * @param size defines the size you want for the cubemap (can be null)
  128357. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128358. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  128359. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  128360. * @returns a new EquiRectangularCubeTextureAssetTask object
  128361. */
  128362. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  128363. /**
  128364. * Remove a task from the assets manager.
  128365. * @param task the task to remove
  128366. */
  128367. removeTask(task: AbstractAssetTask): void;
  128368. private _decreaseWaitingTasksCount;
  128369. private _runTask;
  128370. /**
  128371. * Reset the AssetsManager and remove all tasks
  128372. * @return the current instance of the AssetsManager
  128373. */
  128374. reset(): AssetsManager;
  128375. /**
  128376. * Start the loading process
  128377. * @return the current instance of the AssetsManager
  128378. */
  128379. load(): AssetsManager;
  128380. /**
  128381. * Start the loading process as an async operation
  128382. * @return a promise returning the list of failed tasks
  128383. */
  128384. loadAsync(): Promise<void>;
  128385. }
  128386. }
  128387. declare module BABYLON {
  128388. /**
  128389. * Wrapper class for promise with external resolve and reject.
  128390. */
  128391. export class Deferred<T> {
  128392. /**
  128393. * The promise associated with this deferred object.
  128394. */
  128395. readonly promise: Promise<T>;
  128396. private _resolve;
  128397. private _reject;
  128398. /**
  128399. * The resolve method of the promise associated with this deferred object.
  128400. */
  128401. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  128402. /**
  128403. * The reject method of the promise associated with this deferred object.
  128404. */
  128405. readonly reject: (reason?: any) => void;
  128406. /**
  128407. * Constructor for this deferred object.
  128408. */
  128409. constructor();
  128410. }
  128411. }
  128412. declare module BABYLON {
  128413. /**
  128414. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  128415. */
  128416. export class MeshExploder {
  128417. private _centerMesh;
  128418. private _meshes;
  128419. private _meshesOrigins;
  128420. private _toCenterVectors;
  128421. private _scaledDirection;
  128422. private _newPosition;
  128423. private _centerPosition;
  128424. /**
  128425. * Explodes meshes from a center mesh.
  128426. * @param meshes The meshes to explode.
  128427. * @param centerMesh The mesh to be center of explosion.
  128428. */
  128429. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  128430. private _setCenterMesh;
  128431. /**
  128432. * Get class name
  128433. * @returns "MeshExploder"
  128434. */
  128435. getClassName(): string;
  128436. /**
  128437. * "Exploded meshes"
  128438. * @returns Array of meshes with the centerMesh at index 0.
  128439. */
  128440. getMeshes(): Array<Mesh>;
  128441. /**
  128442. * Explodes meshes giving a specific direction
  128443. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  128444. */
  128445. explode(direction?: number): void;
  128446. }
  128447. }
  128448. declare module BABYLON {
  128449. /**
  128450. * Class used to help managing file picking and drag'n'drop
  128451. */
  128452. export class FilesInput {
  128453. /**
  128454. * List of files ready to be loaded
  128455. */
  128456. static readonly FilesToLoad: {
  128457. [key: string]: File;
  128458. };
  128459. /**
  128460. * Callback called when a file is processed
  128461. */
  128462. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  128463. private _engine;
  128464. private _currentScene;
  128465. private _sceneLoadedCallback;
  128466. private _progressCallback;
  128467. private _additionalRenderLoopLogicCallback;
  128468. private _textureLoadingCallback;
  128469. private _startingProcessingFilesCallback;
  128470. private _onReloadCallback;
  128471. private _errorCallback;
  128472. private _elementToMonitor;
  128473. private _sceneFileToLoad;
  128474. private _filesToLoad;
  128475. /**
  128476. * Creates a new FilesInput
  128477. * @param engine defines the rendering engine
  128478. * @param scene defines the hosting scene
  128479. * @param sceneLoadedCallback callback called when scene is loaded
  128480. * @param progressCallback callback called to track progress
  128481. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  128482. * @param textureLoadingCallback callback called when a texture is loading
  128483. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  128484. * @param onReloadCallback callback called when a reload is requested
  128485. * @param errorCallback callback call if an error occurs
  128486. */
  128487. 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);
  128488. private _dragEnterHandler;
  128489. private _dragOverHandler;
  128490. private _dropHandler;
  128491. /**
  128492. * Calls this function to listen to drag'n'drop events on a specific DOM element
  128493. * @param elementToMonitor defines the DOM element to track
  128494. */
  128495. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  128496. /**
  128497. * Release all associated resources
  128498. */
  128499. dispose(): void;
  128500. private renderFunction;
  128501. private drag;
  128502. private drop;
  128503. private _traverseFolder;
  128504. private _processFiles;
  128505. /**
  128506. * Load files from a drop event
  128507. * @param event defines the drop event to use as source
  128508. */
  128509. loadFiles(event: any): void;
  128510. private _processReload;
  128511. /**
  128512. * Reload the current scene from the loaded files
  128513. */
  128514. reload(): void;
  128515. }
  128516. }
  128517. declare module BABYLON {
  128518. /**
  128519. * Defines the root class used to create scene optimization to use with SceneOptimizer
  128520. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128521. */
  128522. export class SceneOptimization {
  128523. /**
  128524. * Defines the priority of this optimization (0 by default which means first in the list)
  128525. */
  128526. priority: number;
  128527. /**
  128528. * Gets a string describing the action executed by the current optimization
  128529. * @returns description string
  128530. */
  128531. getDescription(): string;
  128532. /**
  128533. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128534. * @param scene defines the current scene where to apply this optimization
  128535. * @param optimizer defines the current optimizer
  128536. * @returns true if everything that can be done was applied
  128537. */
  128538. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128539. /**
  128540. * Creates the SceneOptimization object
  128541. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  128542. * @param desc defines the description associated with the optimization
  128543. */
  128544. constructor(
  128545. /**
  128546. * Defines the priority of this optimization (0 by default which means first in the list)
  128547. */
  128548. priority?: number);
  128549. }
  128550. /**
  128551. * Defines an optimization used to reduce the size of render target textures
  128552. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128553. */
  128554. export class TextureOptimization extends SceneOptimization {
  128555. /**
  128556. * Defines the priority of this optimization (0 by default which means first in the list)
  128557. */
  128558. priority: number;
  128559. /**
  128560. * 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
  128561. */
  128562. maximumSize: number;
  128563. /**
  128564. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  128565. */
  128566. step: number;
  128567. /**
  128568. * Gets a string describing the action executed by the current optimization
  128569. * @returns description string
  128570. */
  128571. getDescription(): string;
  128572. /**
  128573. * Creates the TextureOptimization object
  128574. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  128575. * @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
  128576. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  128577. */
  128578. constructor(
  128579. /**
  128580. * Defines the priority of this optimization (0 by default which means first in the list)
  128581. */
  128582. priority?: number,
  128583. /**
  128584. * 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
  128585. */
  128586. maximumSize?: number,
  128587. /**
  128588. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  128589. */
  128590. step?: number);
  128591. /**
  128592. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128593. * @param scene defines the current scene where to apply this optimization
  128594. * @param optimizer defines the current optimizer
  128595. * @returns true if everything that can be done was applied
  128596. */
  128597. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128598. }
  128599. /**
  128600. * Defines an optimization used to increase or decrease the rendering resolution
  128601. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128602. */
  128603. export class HardwareScalingOptimization extends SceneOptimization {
  128604. /**
  128605. * Defines the priority of this optimization (0 by default which means first in the list)
  128606. */
  128607. priority: number;
  128608. /**
  128609. * Defines the maximum scale to use (2 by default)
  128610. */
  128611. maximumScale: number;
  128612. /**
  128613. * Defines the step to use between two passes (0.5 by default)
  128614. */
  128615. step: number;
  128616. private _currentScale;
  128617. private _directionOffset;
  128618. /**
  128619. * Gets a string describing the action executed by the current optimization
  128620. * @return description string
  128621. */
  128622. getDescription(): string;
  128623. /**
  128624. * Creates the HardwareScalingOptimization object
  128625. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  128626. * @param maximumScale defines the maximum scale to use (2 by default)
  128627. * @param step defines the step to use between two passes (0.5 by default)
  128628. */
  128629. constructor(
  128630. /**
  128631. * Defines the priority of this optimization (0 by default which means first in the list)
  128632. */
  128633. priority?: number,
  128634. /**
  128635. * Defines the maximum scale to use (2 by default)
  128636. */
  128637. maximumScale?: number,
  128638. /**
  128639. * Defines the step to use between two passes (0.5 by default)
  128640. */
  128641. step?: number);
  128642. /**
  128643. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128644. * @param scene defines the current scene where to apply this optimization
  128645. * @param optimizer defines the current optimizer
  128646. * @returns true if everything that can be done was applied
  128647. */
  128648. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128649. }
  128650. /**
  128651. * Defines an optimization used to remove shadows
  128652. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128653. */
  128654. export class ShadowsOptimization extends SceneOptimization {
  128655. /**
  128656. * Gets a string describing the action executed by the current optimization
  128657. * @return description string
  128658. */
  128659. getDescription(): string;
  128660. /**
  128661. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128662. * @param scene defines the current scene where to apply this optimization
  128663. * @param optimizer defines the current optimizer
  128664. * @returns true if everything that can be done was applied
  128665. */
  128666. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128667. }
  128668. /**
  128669. * Defines an optimization used to turn post-processes off
  128670. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128671. */
  128672. export class PostProcessesOptimization extends SceneOptimization {
  128673. /**
  128674. * Gets a string describing the action executed by the current optimization
  128675. * @return description string
  128676. */
  128677. getDescription(): string;
  128678. /**
  128679. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128680. * @param scene defines the current scene where to apply this optimization
  128681. * @param optimizer defines the current optimizer
  128682. * @returns true if everything that can be done was applied
  128683. */
  128684. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128685. }
  128686. /**
  128687. * Defines an optimization used to turn lens flares off
  128688. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128689. */
  128690. export class LensFlaresOptimization extends SceneOptimization {
  128691. /**
  128692. * Gets a string describing the action executed by the current optimization
  128693. * @return description string
  128694. */
  128695. getDescription(): string;
  128696. /**
  128697. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128698. * @param scene defines the current scene where to apply this optimization
  128699. * @param optimizer defines the current optimizer
  128700. * @returns true if everything that can be done was applied
  128701. */
  128702. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128703. }
  128704. /**
  128705. * Defines an optimization based on user defined callback.
  128706. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128707. */
  128708. export class CustomOptimization extends SceneOptimization {
  128709. /**
  128710. * Callback called to apply the custom optimization.
  128711. */
  128712. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  128713. /**
  128714. * Callback called to get custom description
  128715. */
  128716. onGetDescription: () => string;
  128717. /**
  128718. * Gets a string describing the action executed by the current optimization
  128719. * @returns description string
  128720. */
  128721. getDescription(): string;
  128722. /**
  128723. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128724. * @param scene defines the current scene where to apply this optimization
  128725. * @param optimizer defines the current optimizer
  128726. * @returns true if everything that can be done was applied
  128727. */
  128728. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128729. }
  128730. /**
  128731. * Defines an optimization used to turn particles off
  128732. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128733. */
  128734. export class ParticlesOptimization extends SceneOptimization {
  128735. /**
  128736. * Gets a string describing the action executed by the current optimization
  128737. * @return description string
  128738. */
  128739. getDescription(): string;
  128740. /**
  128741. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128742. * @param scene defines the current scene where to apply this optimization
  128743. * @param optimizer defines the current optimizer
  128744. * @returns true if everything that can be done was applied
  128745. */
  128746. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128747. }
  128748. /**
  128749. * Defines an optimization used to turn render targets off
  128750. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128751. */
  128752. export class RenderTargetsOptimization extends SceneOptimization {
  128753. /**
  128754. * Gets a string describing the action executed by the current optimization
  128755. * @return description string
  128756. */
  128757. getDescription(): string;
  128758. /**
  128759. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128760. * @param scene defines the current scene where to apply this optimization
  128761. * @param optimizer defines the current optimizer
  128762. * @returns true if everything that can be done was applied
  128763. */
  128764. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128765. }
  128766. /**
  128767. * Defines an optimization used to merge meshes with compatible materials
  128768. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128769. */
  128770. export class MergeMeshesOptimization extends SceneOptimization {
  128771. private static _UpdateSelectionTree;
  128772. /**
  128773. * Gets or sets a boolean which defines if optimization octree has to be updated
  128774. */
  128775. /**
  128776. * Gets or sets a boolean which defines if optimization octree has to be updated
  128777. */
  128778. static UpdateSelectionTree: boolean;
  128779. /**
  128780. * Gets a string describing the action executed by the current optimization
  128781. * @return description string
  128782. */
  128783. getDescription(): string;
  128784. private _canBeMerged;
  128785. /**
  128786. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128787. * @param scene defines the current scene where to apply this optimization
  128788. * @param optimizer defines the current optimizer
  128789. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  128790. * @returns true if everything that can be done was applied
  128791. */
  128792. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  128793. }
  128794. /**
  128795. * Defines a list of options used by SceneOptimizer
  128796. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128797. */
  128798. export class SceneOptimizerOptions {
  128799. /**
  128800. * Defines the target frame rate to reach (60 by default)
  128801. */
  128802. targetFrameRate: number;
  128803. /**
  128804. * Defines the interval between two checkes (2000ms by default)
  128805. */
  128806. trackerDuration: number;
  128807. /**
  128808. * Gets the list of optimizations to apply
  128809. */
  128810. optimizations: SceneOptimization[];
  128811. /**
  128812. * Creates a new list of options used by SceneOptimizer
  128813. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  128814. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  128815. */
  128816. constructor(
  128817. /**
  128818. * Defines the target frame rate to reach (60 by default)
  128819. */
  128820. targetFrameRate?: number,
  128821. /**
  128822. * Defines the interval between two checkes (2000ms by default)
  128823. */
  128824. trackerDuration?: number);
  128825. /**
  128826. * Add a new optimization
  128827. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  128828. * @returns the current SceneOptimizerOptions
  128829. */
  128830. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  128831. /**
  128832. * Add a new custom optimization
  128833. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  128834. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  128835. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  128836. * @returns the current SceneOptimizerOptions
  128837. */
  128838. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  128839. /**
  128840. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  128841. * @param targetFrameRate defines the target frame rate (60 by default)
  128842. * @returns a SceneOptimizerOptions object
  128843. */
  128844. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  128845. /**
  128846. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  128847. * @param targetFrameRate defines the target frame rate (60 by default)
  128848. * @returns a SceneOptimizerOptions object
  128849. */
  128850. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  128851. /**
  128852. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  128853. * @param targetFrameRate defines the target frame rate (60 by default)
  128854. * @returns a SceneOptimizerOptions object
  128855. */
  128856. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  128857. }
  128858. /**
  128859. * Class used to run optimizations in order to reach a target frame rate
  128860. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128861. */
  128862. export class SceneOptimizer implements IDisposable {
  128863. private _isRunning;
  128864. private _options;
  128865. private _scene;
  128866. private _currentPriorityLevel;
  128867. private _targetFrameRate;
  128868. private _trackerDuration;
  128869. private _currentFrameRate;
  128870. private _sceneDisposeObserver;
  128871. private _improvementMode;
  128872. /**
  128873. * Defines an observable called when the optimizer reaches the target frame rate
  128874. */
  128875. onSuccessObservable: Observable<SceneOptimizer>;
  128876. /**
  128877. * Defines an observable called when the optimizer enables an optimization
  128878. */
  128879. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  128880. /**
  128881. * Defines an observable called when the optimizer is not able to reach the target frame rate
  128882. */
  128883. onFailureObservable: Observable<SceneOptimizer>;
  128884. /**
  128885. * Gets a boolean indicating if the optimizer is in improvement mode
  128886. */
  128887. readonly isInImprovementMode: boolean;
  128888. /**
  128889. * Gets the current priority level (0 at start)
  128890. */
  128891. readonly currentPriorityLevel: number;
  128892. /**
  128893. * Gets the current frame rate checked by the SceneOptimizer
  128894. */
  128895. readonly currentFrameRate: number;
  128896. /**
  128897. * Gets or sets the current target frame rate (60 by default)
  128898. */
  128899. /**
  128900. * Gets or sets the current target frame rate (60 by default)
  128901. */
  128902. targetFrameRate: number;
  128903. /**
  128904. * Gets or sets the current interval between two checks (every 2000ms by default)
  128905. */
  128906. /**
  128907. * Gets or sets the current interval between two checks (every 2000ms by default)
  128908. */
  128909. trackerDuration: number;
  128910. /**
  128911. * Gets the list of active optimizations
  128912. */
  128913. readonly optimizations: SceneOptimization[];
  128914. /**
  128915. * Creates a new SceneOptimizer
  128916. * @param scene defines the scene to work on
  128917. * @param options defines the options to use with the SceneOptimizer
  128918. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  128919. * @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)
  128920. */
  128921. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  128922. /**
  128923. * Stops the current optimizer
  128924. */
  128925. stop(): void;
  128926. /**
  128927. * Reset the optimizer to initial step (current priority level = 0)
  128928. */
  128929. reset(): void;
  128930. /**
  128931. * Start the optimizer. By default it will try to reach a specific framerate
  128932. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  128933. */
  128934. start(): void;
  128935. private _checkCurrentState;
  128936. /**
  128937. * Release all resources
  128938. */
  128939. dispose(): void;
  128940. /**
  128941. * Helper function to create a SceneOptimizer with one single line of code
  128942. * @param scene defines the scene to work on
  128943. * @param options defines the options to use with the SceneOptimizer
  128944. * @param onSuccess defines a callback to call on success
  128945. * @param onFailure defines a callback to call on failure
  128946. * @returns the new SceneOptimizer object
  128947. */
  128948. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  128949. }
  128950. }
  128951. declare module BABYLON {
  128952. /**
  128953. * Class used to serialize a scene into a string
  128954. */
  128955. export class SceneSerializer {
  128956. /**
  128957. * Clear cache used by a previous serialization
  128958. */
  128959. static ClearCache(): void;
  128960. /**
  128961. * Serialize a scene into a JSON compatible object
  128962. * @param scene defines the scene to serialize
  128963. * @returns a JSON compatible object
  128964. */
  128965. static Serialize(scene: Scene): any;
  128966. /**
  128967. * Serialize a mesh into a JSON compatible object
  128968. * @param toSerialize defines the mesh to serialize
  128969. * @param withParents defines if parents must be serialized as well
  128970. * @param withChildren defines if children must be serialized as well
  128971. * @returns a JSON compatible object
  128972. */
  128973. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  128974. }
  128975. }
  128976. declare module BABYLON {
  128977. /**
  128978. * Class used to host texture specific utilities
  128979. */
  128980. export class TextureTools {
  128981. /**
  128982. * Uses the GPU to create a copy texture rescaled at a given size
  128983. * @param texture Texture to copy from
  128984. * @param width defines the desired width
  128985. * @param height defines the desired height
  128986. * @param useBilinearMode defines if bilinear mode has to be used
  128987. * @return the generated texture
  128988. */
  128989. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  128990. }
  128991. }
  128992. declare module BABYLON {
  128993. /**
  128994. * This represents the different options available for the video capture.
  128995. */
  128996. export interface VideoRecorderOptions {
  128997. /** Defines the mime type of the video. */
  128998. mimeType: string;
  128999. /** Defines the FPS the video should be recorded at. */
  129000. fps: number;
  129001. /** Defines the chunk size for the recording data. */
  129002. recordChunckSize: number;
  129003. /** The audio tracks to attach to the recording. */
  129004. audioTracks?: MediaStreamTrack[];
  129005. }
  129006. /**
  129007. * This can help with recording videos from BabylonJS.
  129008. * This is based on the available WebRTC functionalities of the browser.
  129009. *
  129010. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  129011. */
  129012. export class VideoRecorder {
  129013. private static readonly _defaultOptions;
  129014. /**
  129015. * Returns whether or not the VideoRecorder is available in your browser.
  129016. * @param engine Defines the Babylon Engine.
  129017. * @returns true if supported otherwise false.
  129018. */
  129019. static IsSupported(engine: Engine): boolean;
  129020. private readonly _options;
  129021. private _canvas;
  129022. private _mediaRecorder;
  129023. private _recordedChunks;
  129024. private _fileName;
  129025. private _resolve;
  129026. private _reject;
  129027. /**
  129028. * True when a recording is already in progress.
  129029. */
  129030. readonly isRecording: boolean;
  129031. /**
  129032. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  129033. * @param engine Defines the BabylonJS Engine you wish to record.
  129034. * @param options Defines options that can be used to customize the capture.
  129035. */
  129036. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  129037. /**
  129038. * Stops the current recording before the default capture timeout passed in the startRecording function.
  129039. */
  129040. stopRecording(): void;
  129041. /**
  129042. * Starts recording the canvas for a max duration specified in parameters.
  129043. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  129044. * If null no automatic download will start and you can rely on the promise to get the data back.
  129045. * @param maxDuration Defines the maximum recording time in seconds.
  129046. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  129047. * @return A promise callback at the end of the recording with the video data in Blob.
  129048. */
  129049. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  129050. /**
  129051. * Releases internal resources used during the recording.
  129052. */
  129053. dispose(): void;
  129054. private _handleDataAvailable;
  129055. private _handleError;
  129056. private _handleStop;
  129057. }
  129058. }
  129059. declare module BABYLON {
  129060. /**
  129061. * Class containing a set of static utilities functions for screenshots
  129062. */
  129063. export class ScreenshotTools {
  129064. /**
  129065. * Captures a screenshot of the current rendering
  129066. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129067. * @param engine defines the rendering engine
  129068. * @param camera defines the source camera
  129069. * @param size This parameter can be set to a single number or to an object with the
  129070. * following (optional) properties: precision, width, height. If a single number is passed,
  129071. * it will be used for both width and height. If an object is passed, the screenshot size
  129072. * will be derived from the parameters. The precision property is a multiplier allowing
  129073. * rendering at a higher or lower resolution
  129074. * @param successCallback defines the callback receives a single parameter which contains the
  129075. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129076. * src parameter of an <img> to display it
  129077. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129078. * Check your browser for supported MIME types
  129079. */
  129080. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  129081. /**
  129082. * Captures a screenshot of the current rendering
  129083. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129084. * @param engine defines the rendering engine
  129085. * @param camera defines the source camera
  129086. * @param size This parameter can be set to a single number or to an object with the
  129087. * following (optional) properties: precision, width, height. If a single number is passed,
  129088. * it will be used for both width and height. If an object is passed, the screenshot size
  129089. * will be derived from the parameters. The precision property is a multiplier allowing
  129090. * rendering at a higher or lower resolution
  129091. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129092. * Check your browser for supported MIME types
  129093. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129094. * to the src parameter of an <img> to display it
  129095. */
  129096. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  129097. /**
  129098. * Generates an image screenshot from the specified camera.
  129099. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129100. * @param engine The engine to use for rendering
  129101. * @param camera The camera to use for rendering
  129102. * @param size This parameter can be set to a single number or to an object with the
  129103. * following (optional) properties: precision, width, height. If a single number is passed,
  129104. * it will be used for both width and height. If an object is passed, the screenshot size
  129105. * will be derived from the parameters. The precision property is a multiplier allowing
  129106. * rendering at a higher or lower resolution
  129107. * @param successCallback The callback receives a single parameter which contains the
  129108. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129109. * src parameter of an <img> to display it
  129110. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129111. * Check your browser for supported MIME types
  129112. * @param samples Texture samples (default: 1)
  129113. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129114. * @param fileName A name for for the downloaded file.
  129115. */
  129116. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  129117. /**
  129118. * Generates an image screenshot from the specified camera.
  129119. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129120. * @param engine The engine to use for rendering
  129121. * @param camera The camera to use for rendering
  129122. * @param size This parameter can be set to a single number or to an object with the
  129123. * following (optional) properties: precision, width, height. If a single number is passed,
  129124. * it will be used for both width and height. If an object is passed, the screenshot size
  129125. * will be derived from the parameters. The precision property is a multiplier allowing
  129126. * rendering at a higher or lower resolution
  129127. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129128. * Check your browser for supported MIME types
  129129. * @param samples Texture samples (default: 1)
  129130. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129131. * @param fileName A name for for the downloaded file.
  129132. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129133. * to the src parameter of an <img> to display it
  129134. */
  129135. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  129136. /**
  129137. * Gets height and width for screenshot size
  129138. * @private
  129139. */
  129140. private static _getScreenshotSize;
  129141. }
  129142. }
  129143. declare module BABYLON {
  129144. /**
  129145. * A cursor which tracks a point on a path
  129146. */
  129147. export class PathCursor {
  129148. private path;
  129149. /**
  129150. * Stores path cursor callbacks for when an onchange event is triggered
  129151. */
  129152. private _onchange;
  129153. /**
  129154. * The value of the path cursor
  129155. */
  129156. value: number;
  129157. /**
  129158. * The animation array of the path cursor
  129159. */
  129160. animations: Animation[];
  129161. /**
  129162. * Initializes the path cursor
  129163. * @param path The path to track
  129164. */
  129165. constructor(path: Path2);
  129166. /**
  129167. * Gets the cursor point on the path
  129168. * @returns A point on the path cursor at the cursor location
  129169. */
  129170. getPoint(): Vector3;
  129171. /**
  129172. * Moves the cursor ahead by the step amount
  129173. * @param step The amount to move the cursor forward
  129174. * @returns This path cursor
  129175. */
  129176. moveAhead(step?: number): PathCursor;
  129177. /**
  129178. * Moves the cursor behind by the step amount
  129179. * @param step The amount to move the cursor back
  129180. * @returns This path cursor
  129181. */
  129182. moveBack(step?: number): PathCursor;
  129183. /**
  129184. * Moves the cursor by the step amount
  129185. * If the step amount is greater than one, an exception is thrown
  129186. * @param step The amount to move the cursor
  129187. * @returns This path cursor
  129188. */
  129189. move(step: number): PathCursor;
  129190. /**
  129191. * Ensures that the value is limited between zero and one
  129192. * @returns This path cursor
  129193. */
  129194. private ensureLimits;
  129195. /**
  129196. * Runs onchange callbacks on change (used by the animation engine)
  129197. * @returns This path cursor
  129198. */
  129199. private raiseOnChange;
  129200. /**
  129201. * Executes a function on change
  129202. * @param f A path cursor onchange callback
  129203. * @returns This path cursor
  129204. */
  129205. onchange(f: (cursor: PathCursor) => void): PathCursor;
  129206. }
  129207. }
  129208. declare module BABYLON {
  129209. /** @hidden */
  129210. export var blurPixelShader: {
  129211. name: string;
  129212. shader: string;
  129213. };
  129214. }
  129215. declare module BABYLON {
  129216. /** @hidden */
  129217. export var pointCloudVertexDeclaration: {
  129218. name: string;
  129219. shader: string;
  129220. };
  129221. }
  129222. // Mixins
  129223. interface Window {
  129224. mozIndexedDB: IDBFactory;
  129225. webkitIndexedDB: IDBFactory;
  129226. msIndexedDB: IDBFactory;
  129227. webkitURL: typeof URL;
  129228. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  129229. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  129230. WebGLRenderingContext: WebGLRenderingContext;
  129231. MSGesture: MSGesture;
  129232. CANNON: any;
  129233. AudioContext: AudioContext;
  129234. webkitAudioContext: AudioContext;
  129235. PointerEvent: any;
  129236. Math: Math;
  129237. Uint8Array: Uint8ArrayConstructor;
  129238. Float32Array: Float32ArrayConstructor;
  129239. mozURL: typeof URL;
  129240. msURL: typeof URL;
  129241. VRFrameData: any; // WebVR, from specs 1.1
  129242. DracoDecoderModule: any;
  129243. setImmediate(handler: (...args: any[]) => void): number;
  129244. }
  129245. interface HTMLCanvasElement {
  129246. requestPointerLock(): void;
  129247. msRequestPointerLock?(): void;
  129248. mozRequestPointerLock?(): void;
  129249. webkitRequestPointerLock?(): void;
  129250. /** Track wether a record is in progress */
  129251. isRecording: boolean;
  129252. /** Capture Stream method defined by some browsers */
  129253. captureStream(fps?: number): MediaStream;
  129254. }
  129255. interface CanvasRenderingContext2D {
  129256. msImageSmoothingEnabled: boolean;
  129257. }
  129258. interface MouseEvent {
  129259. mozMovementX: number;
  129260. mozMovementY: number;
  129261. webkitMovementX: number;
  129262. webkitMovementY: number;
  129263. msMovementX: number;
  129264. msMovementY: number;
  129265. }
  129266. interface Navigator {
  129267. mozGetVRDevices: (any: any) => any;
  129268. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  129269. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  129270. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  129271. webkitGetGamepads(): Gamepad[];
  129272. msGetGamepads(): Gamepad[];
  129273. webkitGamepads(): Gamepad[];
  129274. }
  129275. interface HTMLVideoElement {
  129276. mozSrcObject: any;
  129277. }
  129278. interface Math {
  129279. fround(x: number): number;
  129280. imul(a: number, b: number): number;
  129281. }
  129282. interface WebGLRenderingContext {
  129283. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  129284. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  129285. vertexAttribDivisor(index: number, divisor: number): void;
  129286. createVertexArray(): any;
  129287. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  129288. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  129289. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  129290. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  129291. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  129292. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  129293. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  129294. // Queries
  129295. createQuery(): WebGLQuery;
  129296. deleteQuery(query: WebGLQuery): void;
  129297. beginQuery(target: number, query: WebGLQuery): void;
  129298. endQuery(target: number): void;
  129299. getQueryParameter(query: WebGLQuery, pname: number): any;
  129300. getQuery(target: number, pname: number): any;
  129301. MAX_SAMPLES: number;
  129302. RGBA8: number;
  129303. READ_FRAMEBUFFER: number;
  129304. DRAW_FRAMEBUFFER: number;
  129305. UNIFORM_BUFFER: number;
  129306. HALF_FLOAT_OES: number;
  129307. RGBA16F: number;
  129308. RGBA32F: number;
  129309. R32F: number;
  129310. RG32F: number;
  129311. RGB32F: number;
  129312. R16F: number;
  129313. RG16F: number;
  129314. RGB16F: number;
  129315. RED: number;
  129316. RG: number;
  129317. R8: number;
  129318. RG8: number;
  129319. UNSIGNED_INT_24_8: number;
  129320. DEPTH24_STENCIL8: number;
  129321. MIN: number;
  129322. MAX: number;
  129323. /* Multiple Render Targets */
  129324. drawBuffers(buffers: number[]): void;
  129325. readBuffer(src: number): void;
  129326. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  129327. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  129328. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  129329. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  129330. // Occlusion Query
  129331. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  129332. ANY_SAMPLES_PASSED: number;
  129333. QUERY_RESULT_AVAILABLE: number;
  129334. QUERY_RESULT: number;
  129335. }
  129336. interface WebGLProgram {
  129337. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  129338. }
  129339. interface EXT_disjoint_timer_query {
  129340. QUERY_COUNTER_BITS_EXT: number;
  129341. TIME_ELAPSED_EXT: number;
  129342. TIMESTAMP_EXT: number;
  129343. GPU_DISJOINT_EXT: number;
  129344. QUERY_RESULT_EXT: number;
  129345. QUERY_RESULT_AVAILABLE_EXT: number;
  129346. queryCounterEXT(query: WebGLQuery, target: number): void;
  129347. createQueryEXT(): WebGLQuery;
  129348. beginQueryEXT(target: number, query: WebGLQuery): void;
  129349. endQueryEXT(target: number): void;
  129350. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  129351. deleteQueryEXT(query: WebGLQuery): void;
  129352. }
  129353. interface WebGLUniformLocation {
  129354. _currentState: any;
  129355. }
  129356. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  129357. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  129358. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  129359. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  129360. interface WebGLRenderingContext {
  129361. readonly RASTERIZER_DISCARD: number;
  129362. readonly DEPTH_COMPONENT24: number;
  129363. readonly TEXTURE_3D: number;
  129364. readonly TEXTURE_2D_ARRAY: number;
  129365. readonly TEXTURE_COMPARE_FUNC: number;
  129366. readonly TEXTURE_COMPARE_MODE: number;
  129367. readonly COMPARE_REF_TO_TEXTURE: number;
  129368. readonly TEXTURE_WRAP_R: number;
  129369. readonly HALF_FLOAT: number;
  129370. readonly RGB8: number;
  129371. readonly RED_INTEGER: number;
  129372. readonly RG_INTEGER: number;
  129373. readonly RGB_INTEGER: number;
  129374. readonly RGBA_INTEGER: number;
  129375. readonly R8_SNORM: number;
  129376. readonly RG8_SNORM: number;
  129377. readonly RGB8_SNORM: number;
  129378. readonly RGBA8_SNORM: number;
  129379. readonly R8I: number;
  129380. readonly RG8I: number;
  129381. readonly RGB8I: number;
  129382. readonly RGBA8I: number;
  129383. readonly R8UI: number;
  129384. readonly RG8UI: number;
  129385. readonly RGB8UI: number;
  129386. readonly RGBA8UI: number;
  129387. readonly R16I: number;
  129388. readonly RG16I: number;
  129389. readonly RGB16I: number;
  129390. readonly RGBA16I: number;
  129391. readonly R16UI: number;
  129392. readonly RG16UI: number;
  129393. readonly RGB16UI: number;
  129394. readonly RGBA16UI: number;
  129395. readonly R32I: number;
  129396. readonly RG32I: number;
  129397. readonly RGB32I: number;
  129398. readonly RGBA32I: number;
  129399. readonly R32UI: number;
  129400. readonly RG32UI: number;
  129401. readonly RGB32UI: number;
  129402. readonly RGBA32UI: number;
  129403. readonly RGB10_A2UI: number;
  129404. readonly R11F_G11F_B10F: number;
  129405. readonly RGB9_E5: number;
  129406. readonly RGB10_A2: number;
  129407. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  129408. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  129409. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  129410. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  129411. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  129412. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  129413. 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;
  129414. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  129415. readonly TRANSFORM_FEEDBACK: number;
  129416. readonly INTERLEAVED_ATTRIBS: number;
  129417. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  129418. createTransformFeedback(): WebGLTransformFeedback;
  129419. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  129420. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  129421. beginTransformFeedback(primitiveMode: number): void;
  129422. endTransformFeedback(): void;
  129423. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  129424. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  129425. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  129426. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  129427. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  129428. }
  129429. interface ImageBitmap {
  129430. readonly width: number;
  129431. readonly height: number;
  129432. close(): void;
  129433. }
  129434. interface WebGLQuery extends WebGLObject {
  129435. }
  129436. declare var WebGLQuery: {
  129437. prototype: WebGLQuery;
  129438. new(): WebGLQuery;
  129439. };
  129440. interface WebGLSampler extends WebGLObject {
  129441. }
  129442. declare var WebGLSampler: {
  129443. prototype: WebGLSampler;
  129444. new(): WebGLSampler;
  129445. };
  129446. interface WebGLSync extends WebGLObject {
  129447. }
  129448. declare var WebGLSync: {
  129449. prototype: WebGLSync;
  129450. new(): WebGLSync;
  129451. };
  129452. interface WebGLTransformFeedback extends WebGLObject {
  129453. }
  129454. declare var WebGLTransformFeedback: {
  129455. prototype: WebGLTransformFeedback;
  129456. new(): WebGLTransformFeedback;
  129457. };
  129458. interface WebGLVertexArrayObject extends WebGLObject {
  129459. }
  129460. declare var WebGLVertexArrayObject: {
  129461. prototype: WebGLVertexArrayObject;
  129462. new(): WebGLVertexArrayObject;
  129463. };
  129464. // Type definitions for WebVR API
  129465. // Project: https://w3c.github.io/webvr/
  129466. // Definitions by: six a <https://github.com/lostfictions>
  129467. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  129468. interface VRDisplay extends EventTarget {
  129469. /**
  129470. * Dictionary of capabilities describing the VRDisplay.
  129471. */
  129472. readonly capabilities: VRDisplayCapabilities;
  129473. /**
  129474. * z-depth defining the far plane of the eye view frustum
  129475. * enables mapping of values in the render target depth
  129476. * attachment to scene coordinates. Initially set to 10000.0.
  129477. */
  129478. depthFar: number;
  129479. /**
  129480. * z-depth defining the near plane of the eye view frustum
  129481. * enables mapping of values in the render target depth
  129482. * attachment to scene coordinates. Initially set to 0.01.
  129483. */
  129484. depthNear: number;
  129485. /**
  129486. * An identifier for this distinct VRDisplay. Used as an
  129487. * association point in the Gamepad API.
  129488. */
  129489. readonly displayId: number;
  129490. /**
  129491. * A display name, a user-readable name identifying it.
  129492. */
  129493. readonly displayName: string;
  129494. readonly isConnected: boolean;
  129495. readonly isPresenting: boolean;
  129496. /**
  129497. * If this VRDisplay supports room-scale experiences, the optional
  129498. * stage attribute contains details on the room-scale parameters.
  129499. */
  129500. readonly stageParameters: VRStageParameters | null;
  129501. /**
  129502. * Passing the value returned by `requestAnimationFrame` to
  129503. * `cancelAnimationFrame` will unregister the callback.
  129504. * @param handle Define the hanle of the request to cancel
  129505. */
  129506. cancelAnimationFrame(handle: number): void;
  129507. /**
  129508. * Stops presenting to the VRDisplay.
  129509. * @returns a promise to know when it stopped
  129510. */
  129511. exitPresent(): Promise<void>;
  129512. /**
  129513. * Return the current VREyeParameters for the given eye.
  129514. * @param whichEye Define the eye we want the parameter for
  129515. * @returns the eye parameters
  129516. */
  129517. getEyeParameters(whichEye: string): VREyeParameters;
  129518. /**
  129519. * Populates the passed VRFrameData with the information required to render
  129520. * the current frame.
  129521. * @param frameData Define the data structure to populate
  129522. * @returns true if ok otherwise false
  129523. */
  129524. getFrameData(frameData: VRFrameData): boolean;
  129525. /**
  129526. * Get the layers currently being presented.
  129527. * @returns the list of VR layers
  129528. */
  129529. getLayers(): VRLayer[];
  129530. /**
  129531. * Return a VRPose containing the future predicted pose of the VRDisplay
  129532. * when the current frame will be presented. The value returned will not
  129533. * change until JavaScript has returned control to the browser.
  129534. *
  129535. * The VRPose will contain the position, orientation, velocity,
  129536. * and acceleration of each of these properties.
  129537. * @returns the pose object
  129538. */
  129539. getPose(): VRPose;
  129540. /**
  129541. * Return the current instantaneous pose of the VRDisplay, with no
  129542. * prediction applied.
  129543. * @returns the current instantaneous pose
  129544. */
  129545. getImmediatePose(): VRPose;
  129546. /**
  129547. * The callback passed to `requestAnimationFrame` will be called
  129548. * any time a new frame should be rendered. When the VRDisplay is
  129549. * presenting the callback will be called at the native refresh
  129550. * rate of the HMD. When not presenting this function acts
  129551. * identically to how window.requestAnimationFrame acts. Content should
  129552. * make no assumptions of frame rate or vsync behavior as the HMD runs
  129553. * asynchronously from other displays and at differing refresh rates.
  129554. * @param callback Define the eaction to run next frame
  129555. * @returns the request handle it
  129556. */
  129557. requestAnimationFrame(callback: FrameRequestCallback): number;
  129558. /**
  129559. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  129560. * Repeat calls while already presenting will update the VRLayers being displayed.
  129561. * @param layers Define the list of layer to present
  129562. * @returns a promise to know when the request has been fulfilled
  129563. */
  129564. requestPresent(layers: VRLayer[]): Promise<void>;
  129565. /**
  129566. * Reset the pose for this display, treating its current position and
  129567. * orientation as the "origin/zero" values. VRPose.position,
  129568. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  129569. * updated when calling resetPose(). This should be called in only
  129570. * sitting-space experiences.
  129571. */
  129572. resetPose(): void;
  129573. /**
  129574. * The VRLayer provided to the VRDisplay will be captured and presented
  129575. * in the HMD. Calling this function has the same effect on the source
  129576. * canvas as any other operation that uses its source image, and canvases
  129577. * created without preserveDrawingBuffer set to true will be cleared.
  129578. * @param pose Define the pose to submit
  129579. */
  129580. submitFrame(pose?: VRPose): void;
  129581. }
  129582. declare var VRDisplay: {
  129583. prototype: VRDisplay;
  129584. new(): VRDisplay;
  129585. };
  129586. interface VRLayer {
  129587. leftBounds?: number[] | Float32Array | null;
  129588. rightBounds?: number[] | Float32Array | null;
  129589. source?: HTMLCanvasElement | null;
  129590. }
  129591. interface VRDisplayCapabilities {
  129592. readonly canPresent: boolean;
  129593. readonly hasExternalDisplay: boolean;
  129594. readonly hasOrientation: boolean;
  129595. readonly hasPosition: boolean;
  129596. readonly maxLayers: number;
  129597. }
  129598. interface VREyeParameters {
  129599. /** @deprecated */
  129600. readonly fieldOfView: VRFieldOfView;
  129601. readonly offset: Float32Array;
  129602. readonly renderHeight: number;
  129603. readonly renderWidth: number;
  129604. }
  129605. interface VRFieldOfView {
  129606. readonly downDegrees: number;
  129607. readonly leftDegrees: number;
  129608. readonly rightDegrees: number;
  129609. readonly upDegrees: number;
  129610. }
  129611. interface VRFrameData {
  129612. readonly leftProjectionMatrix: Float32Array;
  129613. readonly leftViewMatrix: Float32Array;
  129614. readonly pose: VRPose;
  129615. readonly rightProjectionMatrix: Float32Array;
  129616. readonly rightViewMatrix: Float32Array;
  129617. readonly timestamp: number;
  129618. }
  129619. interface VRPose {
  129620. readonly angularAcceleration: Float32Array | null;
  129621. readonly angularVelocity: Float32Array | null;
  129622. readonly linearAcceleration: Float32Array | null;
  129623. readonly linearVelocity: Float32Array | null;
  129624. readonly orientation: Float32Array | null;
  129625. readonly position: Float32Array | null;
  129626. readonly timestamp: number;
  129627. }
  129628. interface VRStageParameters {
  129629. sittingToStandingTransform?: Float32Array;
  129630. sizeX?: number;
  129631. sizeY?: number;
  129632. }
  129633. interface Navigator {
  129634. getVRDisplays(): Promise<VRDisplay[]>;
  129635. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  129636. }
  129637. interface Window {
  129638. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  129639. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  129640. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  129641. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  129642. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  129643. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  129644. }
  129645. interface Gamepad {
  129646. readonly displayId: number;
  129647. }
  129648. type XRSessionMode =
  129649. | "inline"
  129650. | "immersive-vr"
  129651. | "immersive-ar";
  129652. type XRReferenceSpaceType =
  129653. | "viewer"
  129654. | "local"
  129655. | "local-floor"
  129656. | "bounded-floor"
  129657. | "unbounded";
  129658. type XREnvironmentBlendMode =
  129659. | "opaque"
  129660. | "additive"
  129661. | "alpha-blend";
  129662. type XRVisibilityState =
  129663. | "visible"
  129664. | "visible-blurred"
  129665. | "hidden";
  129666. type XRHandedness =
  129667. | "none"
  129668. | "left"
  129669. | "right";
  129670. type XRTargetRayMode =
  129671. | "gaze"
  129672. | "tracked-pointer"
  129673. | "screen";
  129674. type XREye =
  129675. | "none"
  129676. | "left"
  129677. | "right";
  129678. interface XRSpace extends EventTarget {
  129679. }
  129680. interface XRRenderState {
  129681. depthNear?: number;
  129682. depthFar?: number;
  129683. inlineVerticalFieldOfView?: number;
  129684. baseLayer?: XRWebGLLayer;
  129685. }
  129686. interface XRInputSource {
  129687. handedness: XRHandedness;
  129688. targetRayMode: XRTargetRayMode;
  129689. targetRaySpace: XRSpace;
  129690. gripSpace: XRSpace | undefined;
  129691. gamepad: Gamepad | undefined;
  129692. profiles: Array<string>;
  129693. }
  129694. interface XRSession {
  129695. addEventListener: Function;
  129696. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  129697. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  129698. requestAnimationFrame: Function;
  129699. end(): Promise<void>;
  129700. renderState: XRRenderState;
  129701. inputSources: Array<XRInputSource>;
  129702. }
  129703. interface XRReferenceSpace extends XRSpace {
  129704. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  129705. onreset: any;
  129706. }
  129707. interface XRFrame {
  129708. session: XRSession;
  129709. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  129710. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  129711. }
  129712. interface XRViewerPose extends XRPose {
  129713. views: Array<XRView>;
  129714. }
  129715. interface XRPose {
  129716. transform: XRRigidTransform;
  129717. emulatedPosition: boolean;
  129718. }
  129719. declare var XRWebGLLayer: {
  129720. prototype: XRWebGLLayer;
  129721. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  129722. };
  129723. interface XRWebGLLayer {
  129724. framebuffer: WebGLFramebuffer;
  129725. framebufferWidth: number;
  129726. framebufferHeight: number;
  129727. getViewport: Function;
  129728. }
  129729. interface XRRigidTransform {
  129730. position: DOMPointReadOnly;
  129731. orientation: DOMPointReadOnly;
  129732. matrix: Float32Array;
  129733. inverse: XRRigidTransform;
  129734. }
  129735. interface XRView {
  129736. eye: XREye;
  129737. projectionMatrix: Float32Array;
  129738. transform: XRRigidTransform;
  129739. }
  129740. interface XRInputSourceChangeEvent {
  129741. session: XRSession;
  129742. removed: Array<XRInputSource>;
  129743. added: Array<XRInputSource>;
  129744. }